Editing Template:Anchor/doc

From Guild of Archivists
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
{{Documentation subpage}}
{{Documentation subpage}}
{{high-use|40,000+}}
{{lua|Module:Anchor}}
{{lua|Module:Anchor}}
<!-- PLEASE ADD CATEGORIES AT THE END OF THIS PAGE, ND INTERWIKIS LINKS TO WIKIDATA -->
<!-- PLEASE ADD CATEGORIES AT THE END OF THIS PAGE, ND INTERWIKIS LINKS TO WIKIDATA -->


The template <nowiki>{{</nowiki>[[{{ns:Template}}:{{BASEPAGENAME}}|{{lc:{{BASEPAGENAME}}}}]]<nowiki>}}</nowiki> inserts one or more HTML fragment identifiers (anchor names) in a page. Those locations can then be linked to using <code><nowiki>[[#Location|...]]</nowiki></code> syntax. {{#ifeq:{{BASEPAGENAME}}|Visible anchor|&nbsp;Unlike {{tl|Anchor}}, the first parameter will be visible text on the page.|}} (Usually the first letter of the ''location'' is capitalised to reflect the common capitalisation used in section headers.)
The template <nowiki>{{</nowiki>[[{{ns:Template}}:{{BASEPAGENAME}}|{{lc:{{BASEPAGENAME}}}}]]<nowiki>}}</nowiki> inserts one or more [[Fragment identifier|HTML fragment identifiers]] (anchor names) in a page. Those locations can then be linked to using <code><nowiki>[[#Location|...]]</nowiki></code> syntax. {{#ifeq:{{BASEPAGENAME}}|Visible anchor|&nbsp;Unlike {{tl|Anchor}}, the first parameter will be visible text on the page.|}} (Usually the first letter of the ''location'' is capitalised to reflect the common capitalisation used in section headers – see [[MOS:HEAD]].)


== Examples ==
== Examples ==
Line 15: Line 16:
{|class="wikitable" style="float:right"
{|class="wikitable" style="float:right"
!Character
!Character
!Code
![[Character entity reference|Code]]
!Template
!Template
!Meaning
!Meaning
Line 22: Line 23:
|<code>&amp;quot;</code> <br /><code>&amp;#34;</code>
|<code>&amp;quot;</code> <br /><code>&amp;#34;</code>
|{{N/a}}
|{{N/a}}
|(double)&nbsp;quotation mark
|(double)&nbsp;[[quotation mark]]
|-
|-
|#
|#
|<code>&amp;#35;</code>
|<code>&amp;#35;</code>
|{{N/a}}
|{{N/a}}
|hash
|[[Number sign|hash]]
|-
|-
|&#124;
|&#124;
|<code>&amp;#124;</code>
|<code>&amp;#124;</code>
|{{tl|!}}
|{{tl|!}}
|pipe
|[[Vertical bar|pipe]]
|-
|-
|&#61;
|&#61;
|<code>&amp;#61;</code>
|<code>&amp;#61;</code>
|{{tl|{{=}}}}
|{{tl|{{=}}}}
|equals
|[[Equals sign|equals]]
|}
|}
* Anchor names that contain any character shown in the table on the right will not work as expected. However, any of these characters can be replaced with the "&amp;#" codes shown for them here. Or, the pipe symbol and equals sign can be worked around with {{tl|!}} and {{tl|{{=}}}}, respectively. Markup code such as {{tag|sup|o}} and {{tag|sub|o}} (superscript and subscript) cannot be used. Most other characters, including white space and punctuation, are not a problem.
* Anchor names that contain any character shown in the table on the right will not work as expected. However, any of these characters can be replaced with the "&amp;#" codes shown for them here. Or, the pipe symbol and equals sign can be worked around with {{tl|!}} and {{tl|{{=}}}}, respectively. Markup code such as {{tag|sup|o}} and {{tag|sub|o}} (superscript and subscript) cannot be used. Most other characters, including white space and punctuation, are not a problem.
* Anchor names should be unique on a page, and should not duplicate any heading titles. Duplicate anchors will not work as expected since the <code><nowiki>#location</nowiki></code> links go to the first anchor with that name. Duplicate anchors result in invalid HTML; you can check for duplicate anchors by running the page through the [[w:W3C Markup Validation Service]].
* Anchor names should be unique on a page, and should not duplicate any heading titles. Duplicate anchors will not work as expected since the <code><nowiki>#location</nowiki></code> links go to the first anchor with that name. Duplicate anchors result in invalid HTML; you can check for duplicate anchors by running the page through the [[W3C Markup Validation Service]].
* If the template is added to a section title then the code will appear in the edit summary window when that section is edited, as in {{nowrap|1="<code><nowiki>/* {{anchor|Issues}}Limitations */ New issue</nowiki></code>"}}. Also, when the section is saved, browsers may not return to the section. Consider using <code><nowiki><span id="..."></span></nowiki></code> directly, rather than using the anchor template, when in a section title.
* If the template is added to a section title then the code will appear in the edit summary window when that section is edited, as in {{nowrap|1="<code><nowiki>/* {{anchor|Issues}}Limitations */ New issue</nowiki></code>"}}. Also, when the section is saved, browsers may not return to the section. Consider using <code><nowiki><span id="..."></span></nowiki></code> directly, rather than using the anchor template, when in a section title.
* Anchor links are case sensitive in some browsers, so treat all anchor links as case sensitive.
* Anchor links are case sensitive in some browsers, so treat all anchor links as case sensitive.
Line 84: Line 85:


=== See also ===
=== See also ===
* {{#ifeq:{{BASEPAGENAME}}|Visible anchor|{{tl|Anchor}}|{{tl|Visible anchor}}}}
* {{tl|Anchored list}}
* {{tl|Anchor comment}}
* {{tl|Shortcut}}
* {{tl|Shortcut}}
* [[WP:ANCHOR]]
* [[WP:TARGET]]


<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox||
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox||
Please note that all contributions to Guild of Archivists may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see GoArch:Copyrights for details). Do not submit copyrighted work without permission!
Cancel Editing help (opens in new window)