Template:Anchor: Difference between revisions
Appearance
Create a minimal anchor template (no ParserFunctions on this wiki, so single-anchor form) (via create-page on MediaWiki MCP Server) |
Document placement (start of heading works) and the ParserFunctions limitation (via update-page on MediaWiki MCP Server) |
||
| Line 4: | Line 4: | ||
Use it for sections whose generated heading anchor cannot be linked to, for example a heading containing math: <code>{</code> and <code>}</code> are illegal in page titles, so <code><nowiki>[[Page#Heading_with_$\mathcal{S}_{n}$]]</nowiki></code> is never parsed as a link. The same applies to <code># < > [ ] |</code>. | Use it for sections whose generated heading anchor cannot be linked to, for example a heading containing math: <code>{</code> and <code>}</code> are illegal in page titles, so <code><nowiki>[[Page#Heading_with_$\mathcal{S}_{n}$]]</nowiki></code> is never parsed as a link. The same applies to <code># < > [ ] |</code>. | ||
Place the call at the start of the section body on the same line as the text | Place the call at the start of the heading (<code>=== <nowiki>{{anchor|Name}}</nowiki>Heading ===</code>) or at the start of the section body on the same line as the text. A call alone on its own line produces an empty paragraph. | ||
The anchor must not contain spaces or any of <code># < > [ ] | { }</code>. | The anchor must not contain spaces or any of <code># < > [ ] | { }</code>. This wiki does not have ParserFunctions, so there is no multi-anchor form: call the template once per anchor. | ||
</noinclude> | </noinclude> | ||
Revision as of 05:55, 18 October 2026
Usage: {{anchor|Anchor_name}} creates the link target #Anchor_name on the current page.
Use it for sections whose generated heading anchor cannot be linked to, for example a heading containing math: { and } are illegal in page titles, so [[Page#Heading_with_$\mathcal{S}_{n}$]] is never parsed as a link. The same applies to # < > [ ] |.
Place the call at the start of the heading (=== {{anchor|Name}}Heading ===) or at the start of the section body on the same line as the text. A call alone on its own line produces an empty paragraph.
The anchor must not contain spaces or any of # < > [ ] | { }. This wiki does not have ParserFunctions, so there is no multi-anchor form: call the template once per anchor.