Template:Visible anchor

From Chevy Wiki
Jump to navigation Jump to search

{{{1}}}

[edit] Template-info.svg Template documentation

Usage

{{Visible anchor}} or its plural alias {{Visible anchors}} will insert one or more HTML anchors in a page at the location of its invocation, enabling direct #Links to this location. Unlike {{Anchor}} and {{Anchors}}, the first parameter will be visible text on the page. See the "Usage details" section for an example.

Linking

After that, you can have links sending directly to the line you marked:

  • With [[#Bar & Baz|link label]] or also assuming use of "link label in a {{Visible anchor}}, then {{Here|link label}} when linking from the same page
  • With [[Article name#Bar & Baz|link label]] or {{There|link label|Article name}} when linking from another page.

Usage details

Code
Before{{Visible anchors|Foo|Bar & Baz|Three}}After
Gives
BeforeTemplate:Visible anchorsAfter

Notes

  • The template will handle up to 10 anchor names, but could very easily be extended to do twice or more. If you accidentally use more than 10 anchors, the template will output an error message in a yellow box like this: Template:Visible anchors This will let you know about it instead of having your extra anchors silently ignored.
  • When used to add anchors to a paragraph of prose, it is preferable to put the template at the very start of the paragraph (stuck to the first word, without space) so as to ensure that incoming #Links will result in the full paragraph being displayed on the reader's screen.
  • Though aliases {{Visible anchor}} and {{Visible anchors}} will work interchangeably, it is preferable to use the singular alias for a single anchor, and the plural alias for multiple anchors. This will allow Special:WhatLinksHere/Template:Visible anchors to track usage of multiple anchors, and could help detecting and converting old-style {{Visible anchor|Foo}}{{Visible anchor|Bar}} to {{Visible anchors|Foo|Bar}}. So for maintenance needs, we'd appreciate you maintain the suggested convention.

Known bug

  • Currently, the anchor code is included in a section-edit summary. For instance, section-editing the "Notes" section of this page will pre-fill your edit summary with:
/* Notes {{Visible anchors|Notes|Details}} */
This is inconsequential for your edit, but can be inconvenient for your edit summary when there are many long anchor names. You can however edit it out to just:
/* Notes */... your normal thorough edit summary
This bug can't be helped in the template itself. It is hoped, not promised, that a future version of the MediaWiki software will skip template calls in headings for section-edit summaries.

Anchor names

  • Due to technical limitations, anchor names can not include characters "#" (hash), "|" (pipe) or "=" (equal). On the other hand, special characters such as " " (space), "," (comma), "&" (ampersand), etc. can be used directly both in anchors and links, because the software will process them automatically into a URL-compatible format.
  • Anchor names should preferably be written in "Sentence case" (as is the standard for headings and thus their anchors); that is, capitalize the first letter of the first word and any proper nouns, but leave the rest lowercase. Examples: "The title of my anchor", "The anchor from Ipanema", etc. Because some browsers have case-sensitive anchors, the anchor name used in a #Link should be absolutely identical to its target (rather than all-lowercase).
  • Anchor names should be unique (with respect to all heading titles and additional anchors) on each page; a duplicate anchor won't work since the #Links will always go to the first homonymous anchor on the page.

Technical

  • The template is based on <span id="anchor" />
  • The final HTML page (as outputted by Wikipedia to the reader's browser) will have converted it to <span id="anchor"></span> instead.
  • The more backward-compatible <a name="anchor" id="anchor"></a> is used by Wikipedia's own headings but disabled for editors in the wikicode and thus not used here.

See also

ar:قالب:Anchor bg:Шаблон:Anchor ca:Plantilla:Anchor cs:Šablona:Anchor da:Skabelon:Anchor de:Vorlage:Anker el:Πρότυπο:Anchor eo:Ŝablono:Anchor eu:Txantiloi:Anchor fa:الگو:Anchor fr:Modèle:Ancre ko:틀:Anchor hsb:Předłoha:Anchor is:Snið:Anchor he:תבנית:עוגן2 ks:Template:Anchor sw:Template:Anchor la:Formula:Anchor hu:Sablon:Anchor mi:Template:Anchor nl:Sjabloon:Anchor ja:Template:Anchor no:Mal:Anchor nn:Mal:Anchor oc:Modèl:Anchor ps:کينډۍ:Anchor nds:Vörlaag:Anchor pl:Szablon:Anchor pt:Predefinição:Anchor ro:Format:Anchor rmy:Sikavno:Anchor ru:Шаблон:Anchor tn:Template:Anchor sq:Stampa:Anchor simple:Template:Anchor sd:Template:Anchor sl:Predloga:Sidro sr:Шаблон:Anchor fi:Malline:Anchor sv:Mall:Anchor te:మూస:Anchor vi:Tiêu bản:Anchor uk:Шаблон:Anchor ur:سانچہ:Anchor yi:מוסטער:Anchor zh:Template:Anchor