Template:Cnw

From Meta, a Wikimedia project coordination wiki
Jump to navigation Jump to search

Template documentation[view] [edit] [history] [purge]

Combination of <code> and <nowiki>.

Unlike with <pre>, wrapping still works.

Usage[edit]

Write "|" between braces of the wikitext to be displayed (and if its last character is a closing brace, also after that), and also inside tags, to avoid their interpretation by the server.

Write "|" in the desired wikitext as {{!}}.


a{{cnw|'''bold''' ''italics'' {|{tc}|} [[link]] '''bold''' ''italics'' '''bold''' ''italics''}}b


gives:


a'''bold''' ''italics'' {{tc}} [[link]] '''bold''' ''italics'' '''bold''' ''italics''b



Compare (not wrapping):

a{{#tag:syntaxhighlight|'''bold''' ''italics'' {{tc}} [[link]] '''bold''' ''italics'' '''bold''' ''italics''|lang=text| enclose="none"}}b

gives


a'''bold''' ''italics'' <span class="nowrap"><code>&#123;&#123;tlc&#124;...&#125;&#125;</code></span> [[link]] '''bold''' ''italics'' '''bold''' ''italics''b


Limitations[edit]

The "|" does not avoid interpretation by the browser. For example, a code like &rarr; is not shown but interpreted by the browser. Also, both a single and multiple newlines are displayed as a space by the browser.


{{cnw|arrow      &rarr; {{tc}}

''italics''
[[link]]}}

gives:


arrow → <span class="nowrap"><code>{{tlc|...}}</code></span> ''italics'' [[link]]


To preserve paragraphs, apply the template for each line separately. To preserve also single newlines, use also <poem> tags.


<poem>
{{cnw|{|{tc}|}}}

{{cnw|''italics''}}
{{cnw|[[link]]}}}}
</poem>

gives:


{{tc}}

''italics''
[[link]]}}


See also[edit]