Difference between revisions of "Template:Samp/doc"

From Summertime Saga Wiki
Jump to: navigation, search
m
m
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
This template is for explicitly indicating that the content inside it represents example output from a computer program or other machine source (automated attendant or interactive voice response call system, exit code of an application, standard output, LCD display, etc.). It uses the XHTML element {{tag|samp}} 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 {{tag|samp|open}} element. Because it uses {{tag|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 {{tlx|kbd}}, which is for example input.
+
The template {{tlg|samp}} is for explicitly indicating that the content inside it represents example output from a computer program or other machine source (automated attendant or interactive voice response call system, exit code of an application, standard output, LCD display, etc.).
 +
 
 +
It uses the XHTML element {{tag|samp}} which exists for this purpose, and applies some styling to it, namely a faint greying out of the text color to visually differentiate it from source code and input. It retains the default monospaced (non‐proportional) font style of the {{tag|samp|open}} element. Because it uses {{tag|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 {{tlg|code=yes|kbd}}, which is for example input.
  
 
== Usage ==
 
== Usage ==
  
The template takes one mandatory parameter, the content to be marked up. If this content contains “=” (an equals sign), the parameter {{em|must}} be explicitly named {{para|1}}, or the template will fail. (This is a limitation of the MediaWiki software, not the template.) It is always safer to use {{para|1}} syntax. It may be used as a container for {{tlx|var}}, {{tlx|varserif}} or {{tag|var}} when the example output contains or consists entirely of a variable. It may also be used with (but not inside) {{tlx|code}}, or with {{tag|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).
+
The template takes one mandatory parameter, the content to be marked up. If this content contains an equals sign “=”, the parameter {{em|must}} be explicitly named {{para|1}}, or the template will fail. (This is a limitation of the MediaWiki software, not the template.) It is always safer to use {{para|1}} syntax. It may be used as a container for {{tlg|code=yes|var}}, {{tlg|code=yes|varserif}} or {{tag|var}} when the example output contains or consists entirely of a variable. It may also be used with (but not inside) {{tlg|code=yes|code}}, or with {{tag|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 {{para|color}} that takes an HTML color name or <code>#{{var|nnnnnn}}</code> color code (in which case the {{code|#}} is mandatory). For accessibility reasons, color should never be the only distinguishing factor, as {{samp|foo|color=red}} and {{samp|foo|color=green}} may be indistinguisahble to color‐blind readers.
 
For cases where it is useful to display the color of the output, there is an optional parameter {{para|color}} that takes an HTML color name or <code>#{{var|nnnnnn}}</code> color code (in which case the {{code|#}} is mandatory). For accessibility reasons, color should never be the only distinguishing factor, as {{samp|foo|color=red}} and {{samp|foo|color=green}} may be indistinguisahble to color‐blind readers.
Line 9: Line 11:
 
There may also be cases where some other aspect of the output may need to be reproduced; the {{para|style}} parameter accepts any complete CSS statement(s), terminating with a semicolon, e.g. {{para|style|font-variant:small-caps; font-style:italic;}}.
 
There may also be cases where some other aspect of the output may need to be reproduced; the {{para|style}} parameter accepts any complete CSS statement(s), terminating with a semicolon, e.g. {{para|style|font-variant:small-caps; font-style:italic;}}.
  
Examples:
+
== Examples ==
* {{tnull|samp|1{{=}}[A]bort, [R]etry, [F]ail?}}: “The error message {{samp|1=[A]bort, [R]etry, [F]ail?}} has been cited as notoriously user‐unfriendly.”
+
 
* {{tnull|samp|%}} with {{tnull|kbd|1{{=}}ssh <nowiki>{{var|hostname}}</nowiki>}}: “At the {{samp|%}} prompt, the user must enter {{kbd|1=ssh {{var|hostname}}}}.”
+
* {{tlg|code=yes|nolink=yes|samp|1{{=}}[A]bort, [R]etry, [F]ail?}}: “The error message {{samp|1=[A]bort, [R]etry, [F]ail?}} has been cited as notoriously user‐unfriendly.”
* {{tnull|samp|Error|color{{=}}red}}, to indicate output color: On failure, the {{samp|Error|color=red}} light activates.
+
* {{tlg|code=yes|nolink=yes|samp|%}} with {{tlg|code=yes|nolink=yes|kbd|1{{=}}ssh <nowiki>{{var|hostname}}</nowiki>}}: “At the {{samp|%}} prompt, the user must enter {{kbd|1=ssh {{var|hostname}}}}.”
* {{tnull|samp|Error|color{{=}}red|style{{=}}font-variant:small-caps;}}, for more customization: On failure, the {{samp|Error|color=red|style=font-variant:small-caps;}} light activates.
+
* {{tlg|code=yes|nolink=yes|samp|Error|color{{=}}red}}, to indicate output color: On failure, the {{samp|Error|color=red}} light activates.
 +
* {{tlg|code=yes|nolink=yes|samp|Error|color{{=}}red|style{{=}}font-variant:small-caps;}}, for more customization: On failure, the {{samp|Error|color=red|style=font-variant:small-caps;}} light activates.
  
[[Category:Templates]]
+
[[Category:Templates]][[Category:Semantic markup templates]][[Category:Templates documentation]]
[[Category:Templates documentation]]
 

Latest revision as of 18:47, 21 July 2020

The template {{samp}} is for explicitly indicating that the content inside it represents example output from a computer program or other machine source (automated attendant or interactive voice response call system, exit code of an application, standard output, LCD display, etc.).

It uses the XHTML element <samp>…</samp> which exists for this purpose, and applies some styling to it, namely a faint greying out of the text color to visually differentiate 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.