Page MenuHomePhabricator

alias __TOC__ to {{#TOC}} and add TOC style options to such parser function
Open, MediumPublicFeature

Description

out of all magic names of the form __some-name__ only __TOC__ inserts something at the place where it is included in the wiki
text. All other of the kind influence only how a page is rendered.

Thus, for the sake of consistency, add another name, like {{#TOC}} or similar, and after a while phase __TOC__ out.

Not proposed here and now, but something possibly worth thinking about: There could later be {{#TOC:parameters}} as to influence the style of the toc, such as with/out numbering,
right/center/left, with/out "hide" button, initially un/hidden, general or page-specific sticky hide, width, CSS-id, CSS-class, etc.


Version: unspecified
Severity: enhancement

Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 10:33 PM
bzimport set Reference to bz17587.
bzimport added a subscriber: Unknown Object (MLST).

{{TOC}} is a bit ofrisk regarding templates that currently exit and do this already.

{{#TOC}} would work I guess, although some of the options listed there seem like overkill / too many options, the following sound useful though. Implementation ala [[File:]] sounds great, so that the order won't matter, nor are parameter names required and the values can be easily localized for content language.

  • left/right (unnamed parameter, default left, inserts a class, styled via shared.css)
  • maxlevel=[1-6] (dont show headings higher than this level)
  • class='' (adds additinonal classes to the default 'toc' class, such as visualClear, or fancy-toc)
Danny_B set Security to None.
Danny_B updated the task description. (Show Details)
Danny_B raised the priority of this task from Low to Medium.Jan 20 2016, 8:11 AM

In T293513: Deprecate and remove ParserOutput::setTOCHTML() I am moving the HTML generation for the ToC to ParserOutput::getText(). It might be easy to add a hook here to allow an extension to change the style of the rendered HTML. Would that work?

@Krinkle's suggestion could probably be implemented to extend the information which goes into the JSON output. It probably wouldn't be hard to allow that to be extensible, so that any args given to {{#toc|foo|bar}} would be visible in ParserOutput::getSections() and thus could be used by an extension to customize the ToC.

Note for the new Vector __TOC__ will not be supported given the table of contents will be always place din the sidebar, however, we are very interested in replacing use cases such as https://en.wikipedia.org/wiki/Template:Compact%20TOC

(

Screen Shot 2021-11-08 at 1.53.36 PM.png (124×1 px, 17 KB)
)

For example if an editor did:
{{#TOC:horizontal=yes}}

We'd be interested in having access to { horizontal: true } in the Skin where we render the table of contents and have special handling for it, so the direction sounds good from my perspective.

Aklapper changed the subtype of this task from "Task" to "Feature Request".Feb 4 2022, 12:24 PM
Aklapper removed a subscriber: Purodha.

Change 884102 had a related patch set uploaded (by Jdlrobson; author: C. Scott Ananian):

[mediawiki/core@master] Provide ability to customize the TOC title, id, and class

https://gerrit.wikimedia.org/r/884102

I have to make a decision about default case for T204370, but we might want to make this {{#toc}} (aka lowercase) instead of {{#TOC}}. The recommendation from Unicode is to make the word case-sensitive, not case-insensitive, since the rules for case folding are hard to localize well.