Extension talk:IndentSections

how to use this?
 * Save it to the LocalSettings.php on your wiki. Sections should be automatically indented from then on without any more work. &mdash; Anonymous Dissident  Talk 11:52, 5 October 2008 (UTC)

this extension only works if you have edit permissions, i had to do this to make it work without edit permissions: --- IndentSections.php.orig	2008-11-10 20:36:39.000000000 +0100 +++ IndentSections.php	2008-11-10 20:36:32.000000000 +0100 @@ -40,12 +40,12 @@ function fnIndentSectionsBeforePageDisplay(&$out) { $text =& $out->mBodytext; for($i = 6; $i > 1; $i -= 1){ -   $pattern = sprintf('/( ? .*?)()/ms', $i, $i-1); +   $pattern = sprintf('/( ?.*?)()/ms', $i, $i-1); $text = preg_replace_callback($pattern, fnIndentSectionsCallback, $text); }  return true; } function fnIndentSectionsCallback($matches){ - return '"' . $matches[1] . '"'. $matches[2]; + return '"' . $matches[1] . '"'. $matches[3]; } should i make these changes to the code?
 * The changes in question don't seem to work with the latest MediaWiki.

Extension - coding changes killed the wiki.
I followed instructions and after modifying the LocalSetting.php file (as instructed), my wiki will no longer load. I am given a message that reads, "Error, Setup.php must be included from the file scope, after DefaultSettings.php"

IndentSections is incompatible with "HeaderTabs"
IndentSections worked as advertised on basic pages, but when I tried to view a page that was using the Headertabs exention ala the "&lt;headertabs /&gt;" the article text failed to display. The page loaded all the overhead like the banner, login tools, sidebar, footer, and even the category tags... it was just the main article content in the middle that was completely missing.

Unless there is a fix for this incompatibility to be issued relatively soon, I would actually like to consider hacking the core mediawiki code to insert the &lt;blockquote&gt; tags manually.

Can anyone tell me which file this simple change could be made?

OR - is there a way to modify the function so that it IGNORES the level 1 (e.g. &lt;h1&gt;) level... this seems to be the only level that the headertabs works on.

Otherewise, this is a great and much desired extension! thanks! -Rich (revansx)

Sections not followed by "higher" sections do not indent
I have noticed that sections, without a higher level section following it, do not get indented as expected. I've tried to make the example as clear as possible - but ultimately any section that does not have a "higher" section following it does not get indented. Timothy.russ (talk) 00:13, 1 November 2012 (UTC)

Single quotes not escaping correctly on output
After upgrading and migrating from Windows to Ubuntu, IndentSections output appears to be leaving backslashes in front of single quote characters in sections that get indented. I have isolated this to the extension through process of elimination though I cannot rule out a change in the regex handling between the Windows/Ubuntu MySQL/PHP implementations or a change in the wiki code itself between 1.18.5 and 1.19.2.

Is anyone else seeing this behavior?

MediaWiki 1.19.2 PHP 5.3.10-1ubuntu3.4 (apache2handler) MySQL 5.5.24-0ubuntu0.12.04.1 Timothy.russ (talk) 00:50, 1 November 2012 (UTC)

=Alternate Solutions= I believe I have two alternate solutions that solve most, if not all, of the issues mentioned by Timothy.russ above.

function fnIndentSectionsBeforePageDisplay(&$out) { $text =& $out->mBodytext; //Section content indented for($i = 6; $i > 1; $i -= 1){ $pattern = sprintf('/( *]+class="(editsection|mw-headline)".+?<\/h%d>)(.+?)(?=(\n$3\n \n"; $text = preg_replace($pattern, $replacement, $text); } //Section indented /*for($i = 6; $i > 2; $i -= 1){ $pattern = sprintf('/( *]+class="(editsection|mw-headline)".+?<\/h%d>.+?)(?=(\n$1\n \n"; $text = preg_replace($pattern, $replacement, $text); }*/ return true; }

This function should replace the function shown above and the one on the main page. You'll notice there are two loops. The first indents the content of each section leaving the header hanging. The second indents the entire section (like the original). Comment out which ever one you don't want to use.

You'll also notice that I didn't use blockquotes. I liked the formating better this way. You could easily give the div a class and style it using CSS which would give you more flexibility than using the blockquotes.

Enjoy.


 * I like this solution - not using the blockquotes has the added benefit of maintaining a consistent right margin. I've also confirmed this does eliminate the unclosed indentaion issue I was seeing before.
 * Any idea what may be causing the issues escaping those slashes in the regex?
 * EDIT It appears this also fixed the escaping issue. Not sure why it didn't seem to immediately.
 * Shame you didn't sig your post, now I can't be sure who to get a Christmas Present for.Timothy.russ (talk) 19:44, 20 December 2012 (UTC)