Template:Normalized pagename/doc

From Yugipedia
< Template:Normalized pagename
Revision as of 10:00, 1 September 2018 by Dinoguy1000 (talk | contribs) (create)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

{{Normalized pagename}} is a template which normalizes a page's name, as returned by {{FULLPAGENAME}} and other page name magic words, by replacing numeric character references and character entity references (collectively, "character references") with the actual character (for instance, &quot; is replaced with "). This is most often useful when using the #ifeq parser function to compare the value of these magic words with values passed into a template via a parameter.

By default, {{Normalized pagename}} uses {{FULLPAGENAME}}, but it accepts an unnamed parameter allowing other values to be used, e.g. {{Normalized pagename|{{PAGENAME}}}}.

Technical details

Characters in page names

Several different characters may be replaced by {{FULLPAGENAME}} and related magic words. The replacements made for a particular title can be viewed using the code {{ #tag: syntaxhighlight | {{PAGENAME:Title}} }}; for instance, for the title "We'll Be There" - Rex & Weevil, this code produces &#34;We&#39;ll Be There&#34; - Rex &#38; Weevil.

On this wiki, the following character replacements are made by {{FULLPAGENAME}} and related magic words. Note that because a lone period (.) is not output (it represents the working directory in Unix-like systems and Microsoft Windows) and a leading colon (:foo) is stripped, they are prefixed by a capital "A"; the other characters are also prefixed for consistency. The asterisk (*) is also shown preceding the "A" since when it is the leading character (*foo), it gets replaced with a character reference. The characters < > [ ] { | } are illegal in page titles in MediaWiki, and the character # introduces the fragment identifier in URLs, so these characters are not listed below ({{FULLPAGENAME}} and related magic words will strip these characters, or output nothing, when they are passed in).

A! A!
A" A&#34;
A$ A$
A% A%
A& A&#38;
A' A&#39;
A( A(
A) A)
A* A*
*A &#42;A
A+ A+
A, A,
A. A.
A/ A/
A: A:
A; A&#59;
A= A&#61;
A? A?
A@ A@
A\ A\
A^ A^
A_ A
A` A`
A~ A~

Replacements

{{Normalized pagename}} performs the following replacements.

Numeric character reference Character entity reference Character
&#34; &quot; "
&#38; &amp; &
&#39; &apos; '
&#59; ;
&#61; =

Why not #titleparts?

{{Normalized pagename}} is written using the #replace string function, even though the #titleparts parser function can perform the same task without requiring multiple functions: {{ #titleparts: {{PAGENAME:"We'll Be There" - Rex & Weevil}} }}"We'll Be There" - Rex & Weevil. This is because #titleparts automatically strips any content after a hash (#), including the hash itself. {{FULLPAGENAME}} and related magic words also strip this content from input, but {{Normalized pagename}} may be passed raw strings directly, without using any magic words, and these strings may contain hashes which should not affect the output. For example, the string Nekogal #2 results in the following outputs:

  • {{PAGENAME:Nekogal #2}} → Nekogal
  • {{ #titleparts: Nekogal #2 }} → Nekogal
  • {{Normalized pagename|Nekogal #2}} → Nekogal #2