Page MenuHomePhabricator

Request: Per page setting for numbering headers
Closed, ResolvedPublic


Author: hans.voss

I use a Wiki (MW1.5rc1) to store knowledge and as a documentation tool.
I like for some pages to show (automatic) heading/section numbering and (most)
other pages to not show heading numbers. So just setting the
UserPreferences.Misc->Auto-number headings to on is not a real good option.

Would it be possible to include some 'directive/pragma' onto the page (like
NOTOC etc) that would turn-on autonumber for just this page (if possible
with an offset maybe?).
Something like:
HEADINGNUMBERS for entire page
{{HEADINGNUMBER}} and {{HEADINGNUMBER|from=5}} for individual headers.

Hans Voss
skype: hans.voss

Version: 1.5.x
Severity: enhancement



Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 8:47 PM
bzimport added a project: MediaWiki-Parser.
bzimport set Reference to bz3254.
bzimport added a subscriber: Unknown Object (MLST).
  • Bug 3256 has been marked as a duplicate of this bug. ***

hans.voss wrote:

If have created a patch for this to the MW 1.5.0 code myself. Modificatons to

three source (.php) files are required


In Parser.php, on line 2456 in the function formatHeadings, just below the line
that says:

$doNumberHeadings = $this->mOptions->getNumberHeadings();

add the following code:

		if (! $doNumberHeadings )
			$doNumberHeadingsObj =& MagicWord::get( MAG_NUMBERHEADINGS );
			if ($doNumberHeadingsObj->matchAndRemove ( $text ) )
				$doNumberHeadings = 1;


In the list of defines for the keywords, as the last define (below line 57) add
the following code:


The number 44 is the next in the sequence. If the MediaWiki coders decide to
implement a new MagicWord this number could become invalid and needs to be updated.


In Language.php the actual keyword needs to be defined. In the list of magic
words definitions (search for TOC to find it. Just below line 196 or there
abouts add the following code:


ayg wrote:

*** This bug has been marked as a duplicate of bug 7832 ***

There is a MediaWiki Extension now at:

supplying NUMBEREDHEADINGS (note the difference!)
doing what is aked for in this bug.