Wikia

Vim Tips Wiki

Changes: Template:Code

Edit

Back to page

(Experiment that may help in some <code> markup cases.)
 
(Use doc subpage.)
 
Line 1: Line 1:
<includeonly><code>{{#tag:nowiki|{{{1}}}}}</code></includeonly><noinclude>
+
<includeonly><code>{{#tag:nowiki|{{{1}}}}}</code></includeonly><noinclude>{{/doc}}</noinclude>
Example: <code><nowiki>{{code|...}}</nowiki></code> generates <code>&lt;code>&lt;nowiki>...&lt;/nowiki>&lt;/code></code> so the <code>...</code> can contain HTML tags. Bug: need ugly workarounds if want <code>=</code> or <code>|</code> or <code>}}</code> and possibly more.
 
</noinclude>
 

Latest revision as of 10:13, July 16, 2012


This template can be used in a tip to create nowiki code samples.

Example:

  • "{{code|Bold <b>, italic <i>}}" displays as "Bold <b>, italic <i>"


Instead of using this template, it is best to use <code> tags to display code samples because that always works and is simple for other editors to understand. For example, <code>:echo 'An example'</code> displays as :echo 'An example'.

Our MediaWiki:Common.css causes text in code tags to not wrap: the above example will not have a line break within the text. The same applies to text produced by the {{code}} template.

Text in code tags obeys the normal rules of wikitext, but the code template displays the text as "nowiki". For example:

  • "<code>some ''italic <u>text</u>''</code>" displays as "some italic text"
  • "{{code|some ''italic <u>text</u>''}}" displays as "some ''italic <u>text</u>''"

However, text in a template parameter must not use:

  • = (workaround is to put 1= before the parameter: {{code|1=:set ts=12}})
  • | (workaround is to use &#124; instead of |)
  • }} (indicates the end of the template)

Around Wikia's network

Random Wiki