Difference between revisions of "Template:Samp/doc"
m (typo) |
m (1 revision) |
(No difference)
|
Latest revision as of 14:42, 23 January 2013
Purpose
This template is for explicitly indicating that the content inside it represents example output from a computer program or other machine source (Automated attendant/Interactive voice response call system, Exit code of an application, Standard output, LCD display, etc.) It uses the [X]HTML element <samp>...</samp>
(sample output) which exists for this purpose, and applies some styling to it, namely a faint greying out of the text color to visually difference it from source code and input. It retains the default monospaced (non-proportional) font style of the <samp>
element. Because it uses <samp>...</samp>
instead of simply applying visual style effects, it is Semantic markup that conveys meaning, and it can be further acted upon by the user agent (e.g. with custom local style sheets). This tag is the exact opposite of {{kbd}}
, which is for example input.
Usage
The template takes one mandatory parameter, the content to be marked up. If this content contains "=" (an equals sign), the parameter must be explicitly named |1=
, or the template will fail. (This is a limitation of the MediaWiki software, not the template.) It is always safer to use |1=
syntax. It may be used as a container for {{var}}
, {{varserif}}
or <var>...</var>
when the example output contains or consists entirely of a variable. It may also be used with (but not inside) {{code}}
, or with <code>...</code>
(it generally should not be used inside the latter, as output is not a part of source code, but something that results from it; however, this style can be used to illustrate computer display of mixed type, as illustrated below).
For cases where it is useful to display the color of the output, there is an optional parameter |color=
that takes an HTML color name or #nnnnnn
color code (in which case the #
is mandatory). For accessibility reasons, color should never be the only distinguishing factor, as foo and foo may be indistinguisahble to color-blind readers.
There may also be cases where some other aspect of the output may need to be reproduced; the |style=
parameter accepts any complete CSS statement(s), terminating with a semicolon, e.g. |style=font-variant:small-caps; font-style:italic;
.
Examples:
-
{{samp|1=[A]bort, [R]etry, [F]ail?}}
: "The error message [A]bort, [R]etry, [F]ail? has been cited as notoriously user-unfriendly." -
{{samp|%}}
with{{kbd|1=ssh {{var|hostname}}}}
: "At the % prompt, the user must enter ssh hostname." -
{{samp|Error|color=red}}
, to indicate output color: On failure, the Error light activates. -
{{samp|Error|color=red|style=font-variant:small-caps;}}
, for more customization: On failure, the Error light activates.
Some of these examples may look slightly different outside this documentation, because the default background color varies by page type (articles are stark white, template documentation pale green, most other pages very pale grey). In-article example:
-
{{samp|1=[A]bort, [R]etry, [F]ail?}}
: "The error message [A]bort, [R]etry, [F]ail? has been cited as notoriously user-unfriendly." -
{{samp|%}}
with{{kbd|1=ssh {{var|hostname}}}}
: "At the % prompt, the user must enter ssh hostname." -
{{samp|Error|color=red}}
, to indicate output color: On failure, the Error light activates. -
{{samp|Error|color=red|style=font-variant:small-caps;}}
, for more customization: On failure, the Error light activates.
See also
- {{strong}} – for semantically indicating strong emphasis instead of simple typographical boldfacing
- {{strongbad}} – same as
{{strong}}
but red like this: Never use{{strongbad}}
in articles. - {{stronggood}} – same as
{{strongbad}}
but green like this: Only use{{stronggood}}
on non-article pages. - {{em}} – similar template for semantically indicating mild emphasis instead of simple typographical italicization
- {{var}} – same as {{varserif}} use for all variables (e.g. strIllustratePrefix), except for 'I' (upper-case i) and 'l' (lower-case L), for which use {{varserif}}
- {{varserif}} – same as {{var}} but uses serif font (e.g. strIllustratePrefix), especially for distinguishing between 'I' (upper-case i) and 'l' (lower-case L) as variables
- {{wikivar}} – for displaying wikicode variables and magicwords as they would appear in source code, e.g.
{{PAGENAME}}
,{{DEFAULTSORT:Lastname, Firstname}}
- {{para}} – for displaying wiki template parameters (
|title=
) or parameters and values (|year=2008
) - {{tlx}} and related – for displaying entire templates (with or without parameters and values) as code
- {{tag}} – for using HTML elements ("tags") in prose (e.g. "When coding HTML
<img>...</img>
tags, always include ...") - {{code}} – for computer source code (e.g. "... always include the
alt=
parameter.") (Note: to nest other templates like{{var}}
inside, use<code>...</code>
instead of{{code}}
) - {{syntaxhighlight}} or {{sxhl}} – wrapper for
<syntaxhighlight>...</syntaxhighlight>
, but will wrap overflowing text - {{deprecated code}} or {{dc}} – for deprecated source code in template documentation, articles on HTML specs, etc.
- {{pre}} – for larger blocks of source code and other pre-formatted text
- {{bq}} – for indented blocks of content, such as block quotations, examples, poems, etc.
- {{kbd}} – for indicating user input
- {{key press}} – for indicating the input of specific keystrokes, e.g. CtrlX
- {{PlayStation key press}} – for indicating PS-style gamepad key presses, e.g. ×
- {{samp}} – for example output