Topic on Extension talk:SectionHide

Some odd formatting in MediaWiki 1.22

7
71.94.151.22 (talkcontribs)

I have noticed two odd things in MediaWiki 1.22...

  • MediaWiki normally indents subsections slightly (at least with the Vector skin I am using) and I like this feature. With the extension installed, however, subsections are no longer indented, apparently because the divs have a new class name. I'm not sure if you can do much about this, but in case anyone else noticed the same thing, I fixed this by adding the following line to Common.css:

div.sectionblocks {padding-left: 20px}

You can adjust the px measurement to make the indentations bigger or smaller, of course.

  • The extension is somehow inserting the following block of white space between headers (right before a new header), which is disorienting and looks bad:


Worse still, if you're moving from a lower-numbered header to a higher-numbered header -- e.g. you have an H2 header, then you have an H3 header -- then it inserts it twice before the higher-numbered header. Needless to say, that's quite a lot of blank space.

I... cannot for the life of me figure out how that's happening. I'm not great with PHP or JavaScript but nothing obvious in the extension code sticks out to me. If I disable the extension, that goes away. I am using the Vector skin.

71.94.151.22 (talkcontribs)

Sorry, the page hangs when I try to edit the code... here is the white space that gets inserted:

<p><br />
</p>

I have also tested it with MonoBook and Modern skins, with the same result.

71.94.151.22 (talkcontribs)

I figured it out! It's some instances of /n in SectionHideHooks.php.

I deleted them in lines 20 and 21, so that they read as follows:

$sectionContent = preg_replace( '/<\/h[2-6]>/', "$0$divstart", $sectionContent);
$sectionContent = $sectionContent."$divend";

I'm not sure what was intended with the /n in the original code, but I suspect most people would rather not have extra white space inserted that way, especially since it's relatively easy to use CSS to edit the padding of div.sectionblocks.

Anyway, THANK YOU SO MUCH FOR THIS EXTENSION. It does everything I want it to!

71.94.151.22 (talkcontribs)

And now that's broken the nesting, i.e. H2 divs get closed before the H3 divs they contain are opened, so collapsing the H2 div only collapses the text up until the H3 header... So I'm guessing the \n is important somehow but I really cannot live with all that white space. I'll keep tinkering with it...

71.94.151.22 (talkcontribs)

Okay, apparently the \n in this line are crucial to preserving the nesting:

$sectionContent = preg_replace( '/<\/h[2-6]>/', "$0\n$divstart\n", $sectionContent);

I got rid of a considerable amount of white space just by removing the \n around $divend but I would really, really like to not have the other whitespace as well... is there any way to get rid of it without breaking the nesting?

Hoggle42 (talkcontribs)

I'll have a look - I suspect it is the interaction between wiki code and parser but we'll see.

Hoggle42 (talkcontribs)

Resolved with version 1.5

The issue was the move from classname editsection to mw-editsection. I've also moved the link to after the edit link so it comes after the title too, and that allows me to use a single preg-replace operation.

I have also removed the editsection class name from the hide all link as that was causing it to indent.

Reply to "Some odd formatting in MediaWiki 1.22"