Last modified: 2014-09-23 23:40:42 UTC
A number of issues, including the (still ongoing) controversies over citation formats, but also numbered figures, equations, etc., which must still be numbered (see Bug 5600), and situations in which numbered lists don't work right (see Bug 4281) would be resolved by the ability to create (possibly more than one) named, auto-incrementing element on a page. Suppose the markup for this is ##_name (though this markup is provided purely for example purposes). Then the first instance of ##_figno on a page will produce a 1, the second a 2, and so forth. Other counters (suppose the same page had numbered equations, numberd by another counter ##_eqno) would not interfere with each other. An extension would be auto-incrementing counters using symbols other than numerals, such as letters or Roman numberals. Maybe ##A_name for A, B, C, ##a_name for a, b, c, ##I_name for I, II, III, ##i_name for i, ii, iii.
I have written a patch to support this. I used syntax like #{counter} First item # Second item # Third item Some intervening text #{} Fourth item A separate list... # First item, list two # Second item list two Back to the original list... #{counter} Fifth item, list one Skip five... #{counter|+5} Tenth item, list one Go to a specific number... #{30} Thirtieth item, list two #{counter|20} Twentieth item, list one
Created attachment 1601 [details] Patch to support this.
BTW I don't have SVN access, someone please commit (to somewhere where experimental code is allowed).
Created attachment 1603 [details] Newer patch: Fix a bug, update parser tests for this patch
Andrew, thank you for the patch. I'm very sorry, but in the time since you provided your patch, MediaWiki's codebase has changed enough that your patch no longer applies cleanly to our trunk. Therefore I'm marking it obsolete and removing the "need-review" and "patch" keywords. We are currently rewriting the parser https://www.mediawiki.org/wiki/Future/Parser_development ; I am cc'ing Gabriel Wicke, who is one od the developers on that effort. If this issue is still one you're interested in fixing, please join us in IRC https://www.mediawiki.org/wiki/MediaWiki_on_IRC and talk with other developers before renewing and possibly revising your approach; it would be great to get your help in the rewrite. Thanks for your interest in improving MediaWiki! And, again, sorry for the very long delay in response.
Comment on attachment 1603 [details] Newer patch: Fix a bug, update parser tests for this patch This patch no longer applies to trunk per Rusty Burchfield's automated testing https://docs.google.com/spreadsheet/ccc?key=0Ah_71HHl7qa7dGtvSms3TGpHQU9NU2Y1VmNzUEUteWc .
Could this be fully or partly solved using CSS counters? http://www.w3.org/TR/CSS21/generate.html#counters or http://dev.opera.com/articles/view/automatic-numbering-with-css-counters/ have some information about this. Doing this in an extension would introduce a lot of dependencies between elements of a page. We are considering to do incremental updates to parts of a page DOM in the future to improve performance and responsiveness, which would be complicated by adding more dependencies.
Wouldn't that require the ability to have per page/category/template/whathever CSS?
Yes, but adding such a thing does not appear to be that hard from a technical point of view and would likely provide the mechanism for other CSS-based solutions too. Browser support seems to be quite good already according to http://www.quirksmode.org/css/contents.html (search for counters). I did not check if the feature set is sufficient, and think it would make sense to evaluate that first. Also relevant is the support for various list-style-type values: http://www.quirksmode.org/css/lists.html.