Difference between revisions of "Template:COinS safe/doc"

From blackwiki
Jump to navigation Jump to search
imported>Anomalocaris
m (insert a pipe)
 
(6 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 
{{Documentation subpage}}
 
{{Documentation subpage}}
<!-- Categories and interwikis go at the bottom of this page. -->
+
<!-- Please add categories at the bottom of this page, and interwikis at Wikidata (see Wikipedia:Wikidata) -->
  
{{High-use|700-}}
+
== Description ==
 +
It is to indicate whether it can be safely used in citation templates. By default, it indicates the template is safe for use.
 +
 
 +
When the template is set as "not safe", the page is placed into {{cl|Templates not safe for use in citation templates}}.
  
 
== Usage ==
 
== Usage ==
This template is a notice for templates that may be used in citation templates. By default, it indicates the template is safe for use as shown above.
+
To indicate a template which can be safely used in citation templates: <code><nowiki>{{COinS safe}}</nowiki></code>
  
To indicate a template that should not be used in a citation template:
+
To indicate a template that should '''NOT''' be used in citation templates: <code><nowiki>{{COinS safe|n}}</nowiki></code>
  
<code><nowiki>{{COinS safe|n}}</nowiki></code>
+
To add extra info after the standard message: {{para|addtext}}
  
{{COinS safe|n}}
+
== Examples ==
 +
{| class="wikitable"
 +
|-
 +
!style="width: 25%;"| Code !! Result
 +
|-
 +
| {{tlx|COinS safe}} || {{COinS safe}}
 +
|-
 +
| {{tlx|COinS safe|n}} || {{COinS safe|n}}
 +
|-
 +
| {{tlx|COinS safe|addtext{{=}}Here is the extra info.}} || {{COinS safe|addtext=Here is the extra info.}}
 +
|-
 +
| {{tlx|COinS safe|n|addtext{{=}}Here is the extra info.}} || {{COinS safe|n|addtext=Here is the extra info.}}
 +
|}
  
* {{para|addtext}} — additional text shown after the main message
+
== Explain COinS issues ==
 
 
When the template is set to not safe, the page is placed into {{cl|Templates not safe for use in citation templates}}.
 
 
 
== Issue ==
 
 
Citation templates such as {{cs1}} and {{cs2}} generate COinS metadata. If a template is used in a citation template field, then it may inject HTML into the metadata.
 
Citation templates such as {{cs1}} and {{cs2}} generate COinS metadata. If a template is used in a citation template field, then it may inject HTML into the metadata.
  
 
Compare the rendered HTML for {{tl|cite book}} with {{para|author}} using no template and using {{tl|smallcaps}}.
 
Compare the rendered HTML for {{tl|cite book}} with {{para|author}} using no template and using {{tl|smallcaps}}.
  
<div style="overflow:auto;">
+
{|
 +
|-
 +
|
 
{{markup
 
{{markup
 
|<nowiki>{{cite book |author=Sam Drucker |title=Title}}</nowiki>
 
|<nowiki>{{cite book |author=Sam Drucker |title=Title}}</nowiki>
Line 30: Line 43:
  
 
|<nowiki>{{cite book |author={{smallcaps|Sam Drucker}} |title=Title}}</nowiki>
 
|<nowiki>{{cite book |author={{smallcaps|Sam Drucker}} |title=Title}}</nowiki>
|{{cite book |author={{smallcaps|Sam Drucker}} |title=Title}}
+
|{{cite book |author={{smallcaps|Sam Drucker}} |title=Title |<!-- adding template-doc-demo in 2018 to remove this page from the error category while preserving the error message --> template-doc-demo=true}}
  
 
{{code|{{cite book |author={{smallcaps|Sam Drucker}} |title=Title}}}}
 
{{code|{{cite book |author={{smallcaps|Sam Drucker}} |title=Title}}}}
 
}}
 
}}
</div>
+
|}
 +
 
 
The author metadata is in the {{code|rft.aulast}} field. In this case, it is percent-encoded and is rendered as <code><nowiki><span class="smallcaps" style="font-variant:small-caps;">Sam Drucker</span></nowiki></code>
 
The author metadata is in the {{code|rft.aulast}} field. In this case, it is percent-encoded and is rendered as <code><nowiki><span class="smallcaps" style="font-variant:small-caps;">Sam Drucker</span></nowiki></code>
  
Line 40: Line 54:
  
 
== See also ==
 
== See also ==
 +
* [[w:Wikipedia:Citation templates|Wikipedia:Citation templates]]
  
<includeonly>
+
<includeonly>{{sandbox other||
<!-- Categories and interwikis go here: -->
+
<!-- Add categories below this line, and interwikis at Wikidata -->
[[Category:Notice and warning templates|{{PAGENAME}}]]
+
[[Category:Notice and warning templates]]
 
+
}}</includeonly>
</includeonly>
 

Latest revision as of 07:54, 12 January 2020

Description

It is to indicate whether it can be safely used in citation templates. By default, it indicates the template is safe for use.

When the template is set as "not safe", the page is placed into Category:Templates not safe for use in citation templates.

Usage

To indicate a template which can be safely used in citation templates: {{COinS safe}}

To indicate a template that should NOT be used in citation templates: {{COinS safe|n}}

To add extra info after the standard message: |addtext=

Examples

Code Result
{{COinS safe}}
{{COinS safe|n}}
{{COinS safe|addtext=Here is the extra info.}}
{{COinS safe|n|addtext=Here is the extra info.}}

Explain COinS issues

Citation templates such as Citation Style 1 and Citation Style 2 generate COinS metadata. If a template is used in a citation template field, then it may inject HTML into the metadata.

Compare the rendered HTML for {{cite book}} with |author= using no template and using {{smallcaps}}.

Markup Renders as
{{cite book |author=Sam Drucker |title=Title}}

Sam Drucker. Title.

<cite id="CITEREFSam_Drucker" class="citation book cs1">Sam Drucker. ''Title''.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=book&rft.btitle=Title&rft.au=Sam+Drucker&rfr_id=info%3Asid%2Fblackwiki.org%3ATemplate%3ACOinS+safe%2Fdoc" class="Z3988"></span>'"`UNIQ--templatestyles-0000000D-QINU`"'

{{cite book |author={{smallcaps|Sam Drucker}} |title=Title}}

Template:Smallcaps. Title.

<cite id="CITEREFTemplate:Smallcaps" class="citation book cs1">[[:Template:Smallcaps]]. ''Title''.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=book&rft.btitle=Title&rft.au=%3ATemplate%3ASmallcaps&rfr_id=info%3Asid%2Fblackwiki.org%3ATemplate%3ACOinS+safe%2Fdoc" class="Z3988"></span>'"`UNIQ--templatestyles-00000011-QINU`"'

The author metadata is in the rft.aulast field. In this case, it is percent-encoded and is rendered as <span class="smallcaps" style="font-variant:small-caps;">Sam Drucker</span>

Reference management software will interpret the entire span as the author name.

See also