The other day, I implemented numbered section headlines in my wiki, which I think is very useful. I suggest that they should be added to the Wikipedia software as well. I'm not very familiar with the PHP source code, so I hope someone else can write the program from my description:
Here is the problem: You have a long and well written article, e.g. http://fr.wikipedia.com/wiki.cgi?Pharaon All it needs is some structure from sections and headings. There is no need really to break it into smaller articles. It's a fine article.
And the solution: In the wiki text, lines that begin with "!" are headings in different levels, like this:
!hahaha <h1>1. hahaha</h1> !hehehe <h1>2. hehehe</h1> !!hoho <h2>2.1 hoho</h2> !!hihi <h2>2.2 hihi</h2> !huhuhu <h1>3. huhuhu</h1> !!!hy <h3>3.0.1 hy</h3>
The number of "!"s indicate the level of heading and numbers are assigned in sequence. Since 3.1 is missing, the level 3 heading that comes immediately after 3. is called 3.0.1.
At the top of the generated HTML code, a short table of content is placed that links to the right section.
Here is some Perl code for UseModWiki that implements this:
my $ToC; my @HeaderStack; sub StoreHeader { my ($bangs, $header) = @_; my $level = length $bangs; while ($#HeaderStack +1 > $level) { pop @HeaderStack; } while ($#HeaderStack +1 < $level) { push @HeaderStack, 0; } $HeaderStack[$level - 1]++; my $num = join ".", @HeaderStack; my $dot = ""; $dot = "." if $level == 1; $ToC .= " - <a href="#$num" >$num$dot $header</a>\n" if $level <= 3; return StoreRaw("<a name="$num"></a><h$level>") . "$num$dot $header" . Store Raw("</h$level>"); }
# in sub WikiLinesToHTML: @HeaderStack = (); $ToC = ""; ... # foreach line in the article... } else { $depth = 0; s/^(!+)(.*)$/&StoreHeader($1, $2)/eo; } ... return $pageHtml if $ToC eq ''; return '<b>' . T('Table of Contents') . '</b> ' . $ToC . '<p>' . $pageHtml;
You should get the idea. It's really simple. Two examples of the use are http://susning.nu/Hello_world http://susning.nu/Schack
wikipedia-l@lists.wikimedia.org