Jump to content

Template talk:Refname rules

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

If a name is quoted when defined, it must also be quoted for additional invocations (i.e. name="something" is not the same as name=something).

[edit]

That does not seem right.

Markup Renders as
<ref name=r1>reference</ref>
<ref name="r1" />
{{reflist}}

[1] [1]

  1. ^ a b reference

Sanitizer.php automatically adds quotes if they are missing, so they are the same. --  Gadget850 talk 02:14, 16 September 2014 (UTC)[reply]

If that is the case, then I think this rule should be updated. From experience in editing, I know that name=something is the same as name="something", and vice versa.
I'd like to suggest rewording this rule as follows:
Optional quotes may be added when the name is defined; in subsequent invocations optional quotes may be either added or omitted (i.e. name="something" is the same as name=something).
I think we could also consider just cutting this rule. It's kind of complicated, and editors will discover this by experience, like I did. It's not really a rule to warn against unexpected results or undefined behavior. – Margin1522 (talk) 02:15, 26 November 2014 (UTC)[reply]
That is a recent addition and I don't know the rationale.[1] --  Gadget850 talk 04:02, 26 November 2014 (UTC)[reply]
In that case, I think I'd like to change my suggestion to delete it, and just trust editors to figure out that optional means optional. But before doing anything I left a note on the Talk page of the editor who added it. He seems to know what he's doing, so maybe there is some rationale that we don't know about. – Margin1522 (talk) 06:13, 26 November 2014 (UTC)[reply]
AlanM1 has replied and says he's sure the quotes used to matter (I believe he's right about that), but now they don't, so we can go ahead and correct it. For now I think the simplest would be to just delete this rule and keep an eye on it in case it changes again. So I will go ahead and do that. – Margin1522 (talk) 03:57, 29 November 2014 (UTC)[reply]
All markup is parsed by Sanitizer.php before being rendered into HTML. Sanitizer cleans up markup, including adding missing quotes. Thus, it does not matter for refnames. --  Gadget850 talk 14:05, 29 November 2014 (UTC)[reply]

Single-quote character works fine

[edit]

A quick test today found that a reference name can use single-quote characters[1] as well as double-quote.[2] I will invoke the single-quoted name.[1] I will also invoke the name defined with single quotes using double quotes.[1] I don't see any point in documenting this - just don't say single quotes are to be used. Mixed quotes around the same name don't work.[3][4] And invoking with no quotes where defined as single quotes also works[1] (previous discussion says this works with references defined with double quotes). Other weird combinations may work, but I haven't tested as they're even more useless; for example, "name'" and 'name"' might be interpreted as if name' and name".

  1. ^ a b c d Example of single-quoted name
  2. ^ Example of double-quoted name
  3. ^ Cite error: The named reference single' was invoked but never defined (see the help page).
  4. ^ Cite error: The named reference single" was invoked but never defined (see the help page).

Best wishes, Pol098 (talk) 17:04, 10 June 2022 (UTC)[reply]

The rules are much the same as for HTML attributes. Delimiters are used to mark the start and end of the ref name, but are only mandatory when the ref name contains certain special characters, otherwise they are optional. When delimiters are used, they may be either the ASCII apostrophe (U+0027) or the ASCII double-quote (U+0022), but whichever type of delimiter is chosen for the start, the delimiter at the end must be the same type; and the name enclosed by them may not contain the same character, but may contain the other one. --Redrose64 🌹 (talk) 23:25, 10 June 2022 (UTC)[reply]

The advantage of consistency

[edit]

Even if single quotes, double quotes, or no quotes render the same, they are very different when search the editing page. One has to search in several different ways to find all instances or one will miss some. -- Valjean (talk) (PING me) 17:02, 10 December 2023 (UTC)[reply]