On Sat, 24 Sep 2005 23:07:07 +1000, Netocrat wrote:
This is a minimal change to add a new magic token that
prevents
numbering of the TOC and to do the same when the user option "Auto-number
headings" under "Misc" in "Preferences" is set.
^^^
Should have been "not set", but since I misinterpreted the purpose of that
preference, I'm not surprised the patch received no attention.
Here's a new patch that deals solely with suppressing TOC/heading
auto-numbering when a __NOTOCNUM__ directive is included in the page.
Same reasoning as originally (e.g. for FAQ pages where deprecated answers
are removed but new content should not reuse that answer's number):
The token directive is useful because some sections in
a wiki may already
include numbering as part of the heading and suppressing auto-numbering is
useful in those cases.
Let me know if there's a more appropriate place to submit this.
Index: includes/Parser.php
===================================================================
RCS file: /cvsroot/wikipedia/phase3/includes/Parser.php,v
retrieving revision 1.533
diff -u -r1.533 Parser.php
--- includes/Parser.php 27 Nov 2005 06:04:41 -0000 1.533
+++ includes/Parser.php 29 Nov 2005 14:09:35 -0000
@@ -2708,6 +2708,11 @@
function formatHeadings( $text, $isMain=true ) {
global $wgMaxTocLevel, $wgContLang, $wgLinkHolders, $wgInterwikiLinkHolders;
+ # do not number TOC entries or corresponding headings if the string
+ # __NOTOCNUM__ (not case-sensitive) occurs in the HTML
+ $mw =& MagicWord::get( MAG_NOTOCNUM );
+ $noTocNum = $mw->matchAndRemove( $text );
+
$doNumberHeadings = $this->mOptions->getNumberHeadings();
$doShowToc = true;
$forceTocHere = false;
@@ -2836,16 +2841,18 @@
$levelCount[$toclevel] = $level;
- # count number of headlines for each level
- @$sublevelCount[$toclevel]++;
- $dot = 0;
- for( $i = 1; $i <= $toclevel; $i++ ) {
- if( !empty( $sublevelCount[$i] ) ) {
- if( $dot ) {
- $numbering .= '.';
+ if (! $noTocNum ) {
+ # count number of headlines for each level
+ @$sublevelCount[$toclevel]++;
+ $dot = 0;
+ for( $i = 1; $i <= $toclevel; $i++ ) {
+ if( !empty( $sublevelCount[$i] ) ) {
+ if( $dot ) {
+ $numbering .= '.';
+ }
+ $numbering .= $wgContLang->formatNum( $sublevelCount[$i] );
+ $dot = 1;
}
- $numbering .= $wgContLang->formatNum( $sublevelCount[$i] );
- $dot = 1;
}
}
}
Index: languages/Language.php
===================================================================
RCS file: /cvsroot/wikipedia/phase3/languages/Language.php,v
retrieving revision 1.741
diff -u -r1.741 Language.php
--- languages/Language.php 28 Nov 2005 23:56:35 -0000 1.741
+++ languages/Language.php 29 Nov 2005 14:09:56 -0000
@@ -203,6 +203,7 @@
# ID CASE SYNONYMS
MAG_REDIRECT => array( 0, '#REDIRECT' ),
MAG_NOTOC => array( 0, '__NOTOC__' ),
+ MAG_NOTOCNUM => array( 0, '__NOTOCNUM__' ),
MAG_FORCETOC => array( 0, '__FORCETOC__' ),
MAG_TOC => array( 0, '__TOC__' ),
MAG_NOEDITSECTION => array( 0, '__NOEDITSECTION__' ),
--
http://members.dodo.com.au/~netocrat