Template:Code/doc: Difference between revisions

From The Unofficial Outwar Wiki
en>Waldyrious
 
No edit summary
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Documentation subpage}}
{{Documentation subpage}}
<!-- Add categories where indicated at the bottom of this page and interwikis at Wikidata -->
== Usage ==
== Usage ==
This is a [[:en:w:Semantic markup|semantic markup]] wrapper template for the [[:en:w:HTML element|HTML element]] {{tag|code}}. It can be used without a parameter to wrap code in a formatted block, with syntax highlighting, or with {{para|inline}} for a leaner presentation.
This is a semantic markup wrapper template for the HTML element {{tag|code}}. It can be used without a parameter to wrap code in a formatted block, with syntax highlighting, or with {{para|inline}} for a leaner presentation.


Example:
Example:
Line 82: Line 81:
== See also ==
== See also ==
* {{tl|inline-code}}
* {{tl|inline-code}}
* {{tl|MW file}}
* {{tl|git}}
* {{tl|Codesample}}
* {{tl|Codesample}}
* {{tl|Terminal}}
<includeonly>{{Sandbox other||
<!-- Categories below this line; interwikis at Wikidata -->
[[Category:Semantic markup templates]]
}}</includeonly>

Latest revision as of 02:18, 10 July 2023

Template:Mbox[[Category:Template documentation pages{{#translation:}}]]

Usage

This is a semantic markup wrapper template for the HTML element ‎<code>...‎</code>. It can be used without a parameter to wrap code in a formatted block, with syntax highlighting, or with |inline= for a leaner presentation.

Example:

{{code|lang=css|font-family: 'Times New Roman', serif;}}

produces:

font-family: 'Times New Roman', serif;

Inline:

{{code|inline=y|lang=css|font-family: 'Times New Roman', serif;}}

produces:

font-family: 'Times New Roman', serif;

and is equivalent to:

<syntaxhighlight inline lang="css">font-family: 'Times New Roman', serif;</syntaxhighlight>

TemplateData

This is the TemplateData documentation for this template used by VisualEditor and other tools.

Code

[[Category:TemplateData documentation{{#translation:}}]]

<templatedata> { "description": "A block or inline source code string.", "format": "block", "params": { "1": { "aliases": [ "code" ], "label": "Code", "description": "The code to display.", "required": true, "type": "string" }, "lang": { "aliases": [ "2" ], "label": "Language", "description": "The programming language of the source code. List of valid values is at: Extension:SyntaxHighlight#Supported_languages", "default": "\n* text (if `inline=true`)\n* bash (if `inline` is not set)\n", "suggested": true, "type": "string" }, "inline": { "label": "Inline?", "description": "Whether to use inline formatting", "autovalue": "1", "type": "string" }, "class": { "label": "Class", "description": "Applies only if `inline=true`", "type": "string" }, "id": { "label": "ID", "description": "Applies only if `inline=true`", "type": "string" }, "style": { "label": "CSS Style", "description": "Applies only if `inline=true`", "type": "string" }, "header": { "label": "Header", "description": "Applies only if `inline` is not set", "type": "line" } }, "paramOrder": [ "lang", "inline", "class", "id", "style", "header", "1" ] } </templatedata>

See also