(Created page with "{{doc subpage}} <!-- ADD DOCUMENTATION BELOW THIS LINE --> This template is used to present markup or code side by side with the rendered output. Parameters: * unnamed 1: Con...") |
Kentsmith9 (talk | contribs) (Updated documentation) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{ | {{Documentation subpage}} | ||
<!-- | <!-- Categories where indicated at the bottom of this page, please. --> | ||
{{TOC right |limit=2}} | |||
This template is used to present markup or code side by side with the output it renders. | |||
==Usage== | |||
Each pair of {{tl|Markup}}'s arguments should be two copies of some [[wikitext]] markup, with the first of the pair enclosed in {{xtag|nowiki}} tags. The template produces output in two columns, the first showing the markup and the second showing how it is rendered. The template accepts up to 40 unnamed parameters, resulting in up to 20 rows of examples. | |||
< | This: | ||
<pre> | |||
{{markup|<nowiki>'''Bold text'''</nowiki>|'''Bold text'''}} | |||
</pre> | |||
Produces this: | |||
{{markup|<nowiki>'''Bold text'''</nowiki>|'''Bold text'''}} | |||
= | In many cases, the markup for both columns are identical, but there are instances where this may need to differ. If none of these issues apply, then you may use {{tlx|mra}} to save yourself from copying the code twice. | ||
* Header markup such as {{code|1===}} will show in the page table of contents; to avoid this, use {{tlx|fake heading}} in the markup for the second column (see example [[#A complex example|below]]). | |||
* Some templates will place the page in a maintenance category, which is usually undesired. For example. | |||
** Instead of {{tlx|citation needed}}, use {{tlx|fake citation needed}} in the second column. | |||
* Some templates may have error checking that places the page in a maintenance category. | |||
** <s>{{cs1}} templates with errors: add {{para|template doc demo|true}} to the template in the second column.</s> | |||
** To avoid this and the associated red error messages make sure that each example on the page uses different sources. | |||
* HTML entities are parsed in the first cell, even with {{xtag|nowiki}} tags. To work around this, replace the <code>&</code> with <code>&amp;</code> in the first column (see example [[#With HTML entities|below]]). | |||
It is advisable to begin both copies of the markup with a [[newline]]; this is necessary if the first line of the markup must start on a new line (such as #, * or ;). | |||
==Examples== | ==Examples== | ||
===Multiple rows=== | |||
{{markup | {{markup | ||
|<nowiki>'''Bold text'''</nowiki>|'''Bold text''' | |<nowiki>'''Bold text'''</nowiki>|'''Bold text''' | ||
|<nowiki>''Italic text''</nowiki>|''Italic text'' | |<nowiki>''Italic text''</nowiki>|''Italic text'' | ||
|<nowiki>< | |<nowiki>[[Internal link]]</nowiki>|[[Internal link]] | ||
|<nowiki> | |||
{{cite book|ref=none|last=Smith|year=2021|title=Smith's book}} | |||
</nowiki>| | |||
{{cite book|ref=none|last=Smith|year=2021|title=Smith's book}} | |||
|<nowiki> | |||
<score>\relative c' { c( b~ c b c b c b c~ c)}</score> | |||
</nowiki>| | |||
<score>\relative c' { c( b~ c b c b c b c~ c)}</score> | |||
}} | |||
===With custom title and column headers=== | |||
{{Markup | |||
| title=How to write about foxes and dogs in Wikipedia. | |||
|t1=Write this in wikitext|t2=and this will appear in the article. | |||
| The quick brown [[fox]] jumps over the lazy [[dog]]. | The quick brown [[fox]] jumps over the lazy [[dog]]. | |||
}} | }} | ||
===A complex example=== | |||
{{ | In this example, {{tl2|Markup}}'s second argument here uses {{tl2|fake heading}} (to avoid headings appearing in the table of contents) and {{tl2|fake citation needed}} (to avoid adding this page to the maintenance list). | ||
|<nowiki>The quick brown fox jumps over the lazy dog.{{#tag:ref|A footnote.<ref>A reference for the footnote.</ref>|group=nb}} The cow jumped over the moon.{{fact}} | |||
{{Markup | |||
| <nowiki>The quick brown fox jumps over the lazy dog.{{#tag:ref|A footnote.<ref>A reference for the footnote.</ref>|group=nb}} The cow jumped over the moon.{{fact}} | |||
==Notes== | == Notes == | ||
{{ | {{reflist|group=nb}} | ||
==References== | == References == | ||
{{ | {{reflist}} | ||
</nowiki> | </nowiki> | ||
|The quick brown fox jumps over the lazy dog.{{#tag:ref|A footnote.<ref>A reference for the footnote.</ref>|group=nb}} The cow jumped over the moon.{{fake | | The quick brown fox jumps over the lazy dog.{{#tag:ref|A footnote.<ref>A reference for the footnote.</ref>|group=nb}} The cow jumped over the moon.{{fake citation needed}} | ||
{{fake heading|sub= | {{fake heading|sub=2|Notes}} | ||
{{ | {{reflist|group=nb}} | ||
{{fake heading|sub= | {{fake heading|sub=2|References}} | ||
{{ | {{reflist|close}} | ||
}} | }} | ||
===With HTML entities=== | |||
{{ | HTML entities are parsed in the markup cell. To work around this, replace the <code>&</code> with <code>&amp;</code> in the first column. | ||
|The | |||
| | {{Markup| <nowiki>&ndash;</nowiki> | –}} | ||
| | |||
|The | ===More examples=== | ||
| | |||
| | {{Markup|<nowiki> | ||
|The | {{cite book |last=White |first=T. H. |title=The Book of Merlyn |year=1977}} | ||
| | </nowiki>| | ||
| | {{cite book |last=White |first=T. H. |title=The Book of Merlyn |year=1977}} | ||
|The | |<nowiki> | ||
{{code|lang=html|{{cite book |last=White |first=T. H. |title=The Book of Merlyn |year=1977}}}} | |||
</nowiki>| | |||
{{code|lang=html|{{cite book |last=White |first=T. H. |title=The Book of Merlyn |year=1977}}}} | |||
}} | }} | ||
''' | ==Typing aid: template {{tl|mra}}== | ||
{{markup| | {{tl|mra}} will duplicate the source text automatically, saving you the trouble of copying the text and adding {{xtag|nowiki}} tags to the first case. | ||
| | |||
| | This: | ||
}} | <pre>{{subst:mra|'''Bold text'''|''Italic text''}}</pre> | ||
Will produce this: | |||
<pre>{{markup| | |||
<nowiki>'''Bold text'''</nowiki>|'''Bold text'''| | |||
<nowiki>''Italic text''</nowiki>|''Italic text''}}</pre> | |||
Which renders as: | |||
{{markup| | |||
<nowiki>'''Bold text'''</nowiki>|'''Bold text'''| | |||
<nowiki>''Italic text''</nowiki>|''Italic text''}} | |||
==See also== | ==See also== | ||
* {{tl|Markup2}} for bulleted and indented markup. | |||
* {{tl|Markupv}} for the vertical presentation (above/below) of markup/code and its output. | |||
* {{tl|Automarkup}} does not require to write the code samples twice. | |||
== TemplateData == | |||
{{TemplateData header}} | |||
<templatedata> | |||
{ | |||
"description": " ", | |||
"paramOrder": [ | |||
"margin-left", | |||
"width", | |||
"style", | |||
"noheaders", | |||
"title", | |||
"colheaderstyle", | |||
"col1headerstyle", | |||
"col1", | |||
"col2headerstyle", | |||
"col2", | |||
"codestyle", | |||
"outputstyle", | |||
"1", | |||
"2", | |||
"3", | |||
"4", | |||
"39", | |||
"40" | |||
], | |||
"params": { | |||
"1": { | |||
"description": "row 1, first column (markup/code)'s content.", | |||
"type": "string" | |||
}, | |||
"2": { | |||
"description": "row 1, second column (output)'s content.", | |||
"type": "string" | |||
}, | |||
"3": { | |||
"description": "row 2, first column's content (etc).", | |||
"type": "string" | |||
}, | |||
"4": { | |||
"description": "row 2, second column's content (etc).", | |||
"type": "string" | |||
}, | |||
"39": { | |||
"description": "First column's content in last possible row.", | |||
"type": "string" | |||
}, | |||
"40": { | |||
"description": "Second column's content in last possible row.", | |||
"type": "string" | |||
}, | |||
"width": { | |||
"description": "To set the table's overall width.", | |||
"type": "string", | |||
"default": "auto" | |||
}, | |||
"margin-left": { | |||
"description": "To set a margin on the table's lefthand side.", | |||
"type": "string", | |||
"default": "0" | |||
}, | |||
"style": { | |||
"description": "For CSS styles amending the table's overall appearance.", | |||
"type": "string" | |||
}, | |||
"title": { | |||
"description": "Title above table.", | |||
"type": "string" | |||
}, | |||
"noheaders": { | |||
"description": "Set (as e.g. noheaders=on) to suppress the columns' headings and table's title.", | |||
"type": "string" | |||
}, | |||
"col1": { | |||
"description": "First column (markup/code)'s heading.", | |||
"type": "string", | |||
"default": "\"Markup\"" | |||
}, | |||
"col2": { | |||
"description": "Second column (output)'s heading.", | |||
"type": "string", | |||
"default": "\"Renders as\"" | |||
}, | |||
"codestyle": { | |||
"description": "Use CSS style code to change the look of content in the Markup column.", | |||
"type": "string", | |||
"aliases": [ | |||
"markupstyle" | |||
], | |||
"label": "Column 1 style", | |||
"example": "white-space: nowrap" | |||
}, | |||
"outputstyle": { | |||
"description": "Use CSS style code to change the look of content in the Renders-as column.", | |||
"type": "string", | |||
"label": "Column 2 style" | |||
}, | |||
"col1headerstyle": { | |||
"description": "For CSS styling to amend the appearance of the first column's heading. Overrides (but does not replace) colheaderstyle.", | |||
"type": "string" | |||
}, | |||
"col2headerstyle": { | |||
"description": "For CSS styling to amend the appearance of the second column's heading. Overrides (but does not replace) colheaderstyle.", | |||
"type": "string" | |||
}, | |||
"colheaderstyle": { | |||
"description": "For CSS styling to amend the appearance of each column's heading.", | |||
"type": "string" | |||
} | |||
} | |||
} | |||
</templatedata> | |||
<includeonly> | <includeonly> | ||
<!-- ADD CATEGORIES BELOW THIS LINE --> | <!-- ADD CATEGORIES BELOW THIS LINE --> | ||
[[Category:Documentation assistance templates]] | [[Category:Documentation assistance templates]] | ||
[[Category:Incomplete templates]] | |||
<!-- ADD INTERWIKIS BELOW THIS LINE --> | <!-- ADD INTERWIKIS BELOW THIS LINE --> | ||
</includeonly> | </includeonly> |
Latest revision as of 02:32, 17 August 2022
This is a documentation subpage for . It contains usage information, categories and other content that is not part of the original template page. |
This template is used to present markup or code side by side with the output it renders.
Usage
Each pair of {{Markup}}'s arguments should be two copies of some wikitext markup, with the first of the pair enclosed in Template:Xtag tags. The template produces output in two columns, the first showing the markup and the second showing how it is rendered. The template accepts up to 40 unnamed parameters, resulting in up to 20 rows of examples.
This:
{{markup|<nowiki>'''Bold text'''</nowiki>|'''Bold text'''}}
Produces this:
Markup | Renders asTemplate:For loop |
---|---|
In many cases, the markup for both columns are identical, but there are instances where this may need to differ. If none of these issues apply, then you may use {{mra}}
to save yourself from copying the code twice.
- Header markup such as
==
will show in the page table of contents; to avoid this, use{{fake heading}}
in the markup for the second column (see example below). - Some templates will place the page in a maintenance category, which is usually undesired. For example.
- Instead of
{{citation needed}}
, use{{fake citation needed}}
in the second column.
- Instead of
- Some templates may have error checking that places the page in a maintenance category.
Template:Cs1 templates with errors: add|template doc demo=true
to the template in the second column.- To avoid this and the associated red error messages make sure that each example on the page uses different sources.
- HTML entities are parsed in the first cell, even with Template:Xtag tags. To work around this, replace the
&
with&
in the first column (see example below).
It is advisable to begin both copies of the markup with a newline; this is necessary if the first line of the markup must start on a new line (such as #, * or ;).
Examples
Multiple rows
Markup | Renders asTemplate:For loop |
---|---|
With custom title and column headers
Write this in wikitext | and this will appear in the article.Template:For loop |
---|---|
A complex example
In this example, Template:Tl2's second argument here uses Template:Tl2 (to avoid headings appearing in the table of contents) and Template:Tl2 (to avoid adding this page to the maintenance list).
Markup | Renders asTemplate:For loop |
---|---|
With HTML entities
HTML entities are parsed in the markup cell. To work around this, replace the &
with &
in the first column.
Markup | Renders asTemplate:For loop |
---|---|
More examples
Markup | Renders asTemplate:For loop |
---|---|
Typing aid: template {{mra}}
{{mra}} will duplicate the source text automatically, saving you the trouble of copying the text and adding Template:Xtag tags to the first case.
This:
{{subst:mra|'''Bold text'''|''Italic text''}}
Will produce this:
{{markup| <nowiki>'''Bold text'''</nowiki>|'''Bold text'''| <nowiki>''Italic text''</nowiki>|''Italic text''}}
Which renders as:
Markup | Renders asTemplate:For loop |
---|---|
See also
- {{Markup2}} for bulleted and indented markup.
- {{Markupv}} for the vertical presentation (above/below) of markup/code and its output.
- {{Automarkup}} does not require to write the code samples twice.
TemplateData
Parameter | Description | Type | Status | |
---|---|---|---|---|
margin-left | margin-left | To set a margin on the table's lefthand side.
| String | optional |
width | width | To set the table's overall width.
| String | optional |
style | style | For CSS styles amending the table's overall appearance. | String | optional |
noheaders | noheaders | Set (as e.g. noheaders=on) to suppress the columns' headings and table's title. | String | optional |
title | title | Title above table. | String | optional |
colheaderstyle | colheaderstyle | For CSS styling to amend the appearance of each column's heading. | String | optional |
col1headerstyle | col1headerstyle | For CSS styling to amend the appearance of the first column's heading. Overrides (but does not replace) colheaderstyle. | String | optional |
col1 | col1 | First column (markup/code)'s heading.
| String | optional |
col2headerstyle | col2headerstyle | For CSS styling to amend the appearance of the second column's heading. Overrides (but does not replace) colheaderstyle. | String | optional |
col2 | col2 | Second column (output)'s heading.
| String | optional |
Column 1 style | codestyle markupstyle | Use CSS style code to change the look of content in the Markup column.
| String | optional |
Column 2 style | outputstyle | Use CSS style code to change the look of content in the Renders-as column. | String | optional |
1 | 1 | row 1, first column (markup/code)'s content. | String | optional |
2 | 2 | row 1, second column (output)'s content. | String | optional |
3 | 3 | row 2, first column's content (etc). | String | optional |
4 | 4 | row 2, second column's content (etc). | String | optional |
39 | 39 | First column's content in last possible row. | String | optional |
40 | 40 | Second column's content in last possible row. | String | optional |