http://test.wikipedia.org/wiki/User:Gangleri/tests/bugzilla/section_links/wiki_syntax provides a wide range of various sections generated using wiki syntax.
The scope of this report is to identify which cases where "return to section" does not work properly *and* wrong autocomment links are generated could be improved.
The set of characters which are not allowed in page titles *differs* from the set of characters which don't make sense in sections (as "#"). Beside this there is a range of characters which require *escaping* when used in anchors (as "&").
However the page provides many examples where the the "text" rendered / displayed in the TOC contains only characters which can be used in "return" anchors and in "autocomment" links. This is mainly T4831: Links in autogenerated summary in page histories may point to wrong section or to nowhere but there are many examples using wiki syntax, TeX etc. where the TOC-text is more suitable as return-to anchor and autocomment as what is generated now. T6987 is only one of them.
Another "discrepancy" I want to address is the multiple identical TOC-texts. A sollution which would make sense is to render the TOC-text *same* as the anchors *automatically*. This will make the problem more visible while editing and they users could easy fix such sections immediately. This is T2111: Return to the correct section after section edit for a heading that exists multiple times. The algorithm should work also for insertion of new sections inserted "out of sequence" by "first in" -> "first number"; "next in" -> "last number++" (because of posible gaps). This will not generate duplicate TOC-texts any more. Existing pages should render according to this algorithm at the next change or while purged. The algorithm would require (sorry Brion) identical handling of spaces and underscores as addressed in T4339.
The examples from the url shows many complications or section headers about known bugs or implementation dependent issues:
[[foo|]] does not render to [[foo]] today - T3034
[[foo bar#foobar|]] does not generate a valid link today but it might generate [[foo bar#foobar|foobar]] in the future - T2845
The main / primary focus should not be on mentioned or documented complications or other curiosities but on *efficiency* and unifying user interface functionality.
There will still be situations (conflicts) where characters used inside the TOC are not valid in anchors. These characters need to be escaped anyway.
Wikies live. After "changing the rules" it will be possible to "simplify" the stored autocomments in existing summary fields. This will not be a manipulation but a improuvement / usefull fix for users.
best regards reinhardt [[user:gangleri]]