Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Template:Pre

Permanently protected template
From Wikipedia, the free encyclopedia
Sample text
Template documentation[view] [edit] [history] [purge]
CSSThis template usesTemplateStyles:

This template implements a version of the functionality provided by theHTML<pre> tag.

Usage

This template supports two parameters

|width= The width of the pre "box"
|space= The way white space is handled in the pre "box"

MarkupRenders as
{{Pre|This Pre-formatcan looklike this.}}
This Pre-formatcan looklike this.

Main differences include:

  • It wraps text that overflows the page.
  • It allows mid-line-breaks (but not always consistently).

Main limitations include:

  • If the text is a single long word, it won't be wrapped and will still break out to the right hand of the page.
  • HTML and wikimarkup aren't disabled as in<pre>...</pre> and are rendered as usual (thus if a parameter contains any wikimarkup, enclose it in<nowiki>...</nowiki>); however, multiple spaces are preserved.

As with<pre> and<code>,{{pre}} displays text in the font specified as the monospace font in the user's browser options, or specified in the user's CSS pages.

Example

Markup

{{Pre|'''First line, markup working:''' and HTML comment<!--HIDDEN--> hidden.'''Second line, long text wrapping:''' all work and no play make jack a dull boy all work and no play make jack a dull boy all work and no play make jack a dull boy all work and no play make jack a dull boy all work and no play make jack a dull boy.Pipes separate parameters, so literal pipes cannot be included.                              ^^^^^^^^^^^^^ Escape them as<nowiki>{{!}}</nowiki> and{{!}} it's{{!}} OK.Similarly,{{=}} is the parameter/value separator so a literal{{=}} must be escaped as<nowiki>{{=}}</nowiki>.<nowiki>Or, between <nowiki>...&lt;/nowiki>, you can include | whatever = you || want.</nowiki>'''Fourth      line,     multiple spaces preserved''' unlike in HTML and wikitext.'''Fifth line, following the previous one'''.'''Last line''' preceded by two blank lines in markup and in display.}}
Result
First line, markup working: and HTML comment  hidden.Second line, long text wrapping: all work and no play make jack a dull boy all work and no play make jack a dull boy all work and no play make jack a dull boy all work and no play make jack a dull boy all work and no play make jack a dull boy.Pipes separate parameters, so literal pipes cannot be included.                              ^^^^^^^^^^^^^ Escape them as {{!}} and | it's | OK.Similarly, = is the the parameter/value separator so a literal = must be escaped as {{=}}.Or, between <nowiki>...</nowiki>, you can include | whatever = you || want.Fourth      line,     multiple spaces preserved unlike in HTML and wikitext.Fifth line, following the previous one.Last line preceded by two blank lines in markup and in display.

Technical details

Sincerevision 619441399, this template uses a hack to output the<pre> element. Seephab:T353697#9470436 for details.

Maintenance categories

TemplateData

This is theTemplateData for this template used byTemplateWizard,VisualEditor and other tools.See a monthly parameter usage report forTemplate:Pre in articles based on its TemplateData.

TemplateData for Pre

The {{pre}} template creates a block of preformatted text, suitable for code. It provides a version of the functionality of the HTML <pre>...</pre> tag. The main difference is that wikitext within the tag is not disabled, but processed normally. Thus, this template can be used to provide examples of code with styling, links, and so on.

Template parameters[Edit template data]

ParameterDescriptionTypeStatus
Text1

The text to wrap in <pre>...</pre> tags. The characters | and = must be escaped in one of several available ways, for instance as {{!}} and {{=}}, respectively.

Contentrequired
Borderborder

Set to ‘no’ if there should be no border around the box.

Suggested values
yesno
Default
yes
Stringoptional
Widthwidth

The width of the <pre> box in CSS syntax (argument to ‘width:’).

Example
80ch
Stringoptional
Spacespace

Indicates how white space is handled in the <pre> box. Argument to the CSS white-space property.

Suggested values
prepre-wrappre-linenowrapnormalinitialinherit
Default
pre-wrap
Stringoptional
Stylestyle

CSS code to apply to the <pre> tag.

Stringoptional

See also

Template  Example output  Use 
{{strong}}Important! To indicate<strong> importance, seriousness, or urgency instead of just simple typographical boldfacing
{{strongbad}} "Never use ..." Same as {{strong}} but in red
{{stronggood}} "Only use ..." Same as {{strong}} but in green
{{em}} "Anemphatic phrase" To indicate<em> stress emphasis (not just purely typographical italicization like for book titles or foreign terms)
{{var}}strPrefix To indicate text is a variable name. Use for any variable names except those including "I" (uppercase i) and/or "l" (lowercase L); for these, {{var serif}} should be used to ensure a noticeable distinction
{{var serif}}strIllustratePrefix (see {{var}} above)
{{tld}}{{DEFAULTSORT:Y, X}} To display wikicode variables andmagic words as they would appear in code
{{para}}|year=2008 To display template parameters with or without values
{{param}}{{{title|alt}}} To display parameters as used in code (i.e. with triple braces), especially to indicate relationships between them. May be combined with {{para}} above
{{param value}}··2·blanks·fore·and·aft·· To display parameter values lightly bordered; replaces <code>...</code>, especially when value contains embedded or leading/trailing blanks; visualized here withmiddot (·) but can use ␠, ▯, or any character.
{{tlx}} etc.{{Template|1|2|...|10}} To display a template call (with or without parameters and values) as code
{{tag}}"The<img>...</img> tags ..." To renderHTML elements ("tags") in prose
{{code}}/{{codett}}"Ensure thealt= parameter ..." To indicate text is source code. To nest other templates within {{code}}, use<code>...</code>.{{codett}} differs only in styling:someMethod becomessomeMethod
{{PreCode}}"FORTH has keyword?BRANCH." Like {{code}}, but prevents line breaks inside the code. Only for very short code parts.
{{subst:codenowiki}}{{small|small text example}} To wrap example code in<code><nowiki>...</nowiki></code>
{{subst:kbdnowiki}}{{large|large text example}} To wrap example code in<kbd><nowiki>...</nowiki></kbd>
{{syntaxhighlight}}    [this is a block template] ( or{{sxhl}})  Wrapper for<syntaxhighlight>...</syntaxhighlight>, but will wrap overflowing text
{{deprecated code}} "Do not use<blink>." ( or{{dc}})  To indicatedeprecated source code in template documentation, articles on HTML specs, etc. The{{dc2}} variant uses strike-through (<blink>) while{{dcr}} uses red (<blink>).
{{pre}}    [this is a block template] For larger blocks of source code and other pre-formatted text
{{quote}}    [this is a block template] For block quotations (only – never for non-quotations)
{{block indent}}    [this is a block template] For indented blocks of material; visually identical to{{quote}} but without quote markup
{{kbd}}user input To indicate user input
{{key press}}Ctrl+x To indicate specific-keystroke input, including combinations
{{key top}}Left shift Similar; includes more symbols, but does not directly support combinations
{{button}}Don't save To indicate a button in a user interface
{{samp}}example output To indicate sample or example output
The abovedocumentation istranscluded fromTemplate:Pre/doc.(edit |history)
Editors can experiment in this template'ssandbox(edit |diff) andtestcases(edit) pages.
Add categories to the/doc subpage.Subpages of this template.
Retrieved from "https://en.wikipedia.org/w/index.php?title=Template:Pre&oldid=1332218524"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2026 Movatter.jp