Шаблон:Samp/doc: различия между версиями
Нет описания правки |
Импортёр (обсуждение | вклад) м (1 версия импортирована) |
(нет различий)
|
Текущая версия от 11:20, 2 мая 2024
Файл:Information icon4.svg |
Ошибка Lua в Модуль:Message_box на строке 113: attempt to index field 'cfg' (a nil value).
Описание[править код]
Шаблон {{Samp}} используется для отображения текста, который является результатом вывода компьютерной программы или скрипта. Браузеры обычно отображают текст в контейнере <Samp></Samp>
с помощью моноширинного шрифта. С помощью стилей можно задать свое собственное оформление.
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.
Применение[править код]
Шаблон имеет один обязательный параметр, содержание будет размечена. Если это содержание, содержит «=» (знак равенства), то параметр должен быть явно указан |1 =
, или шаблон не будет.
(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.