Difference between revisions of "Template:Pre/doc"

From Ava Zinn Wiki
Jump to: navigation, search
[unchecked revision][unchecked revision]
(See also)
m (31 revisions from wikipedia:Template:Pre/doc)
 
(14 intermediate revisions by 11 users not shown)
Line 1: Line 1:
 
{{Documentation subpage}}
 
{{Documentation subpage}}
 
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE -->
 
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE -->
{{mergefrom|Pre2|date=November 2008}}
 
{{tl|{{PAGENAME}}}} mimics the appearance of <CODE>&lt;pre&gt;&lt;/pre&gt;</CODE> tags as rendered by the [[WP:Skin|monobook skin]].
 
  
==Usage==
+
This template implements a version of the functionality provided by the [[HTML]] {{tag|pre|o}} tag.
  
<pre>
+
===Usage===
{{Pre|
+
{{markup
 +
|<nowiki>{{Pre|
 +
This Pre-format
 +
 
 +
can look
 +
 
 +
like this.
 +
}}</nowiki>
 +
|{{Pre|
 
This Pre-format
 
This Pre-format
  
Line 14: Line 20:
 
like this.
 
like this.
 
}}
 
}}
</pre>
+
}}
 
 
 
Main differences include:
 
Main differences include:
 
+
* It wraps text that overflows the page.
* It disallows the text to overflow the page.
 
 
* It allows mid-line-breaks (but not always consistently).
 
* It allows mid-line-breaks (but not always consistently).
  
 
Main limitations include:
 
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.
 
* 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 and are rendered as usual (thus if a parameter might contain any wikitext, enclose it in <CODE><NOWIKI><NOWIKI></NOWIKI></NOWIKI></CODE> tags); similarly, multiple spaces are treated as a single one.
+
* HTML and wikimarkup aren't disabled as in {{tag|pre}} and are rendered as usual (thus if a parameter contains any wikimarkup, enclose it in {{tag|nowiki}}); similarly, multiple spaces are treated as a single one.
 
* If there are only two lines, they will be stuck together, even if the source has a blank line between them.
 
* If there are only two lines, they will be stuck together, even if the source has a blank line between them.
  
As with <NOWIKI><pre>, <TT>, and <CODE></NOWIKI>, the font used by {{tl|Pre}} is the one selected by the user in his browser for fixed-width display, or customized in his personal CSS.
+
As with {{tag|pre|o}} and {{tag|code|o}}, {{tl|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==
+
===Example===
 +
'''Markup'''
  
; Code
+
<pre>
 
+
{{Pre|
<pre>{{Pre|
 
 
'''First line, markup working:''' and HTML comment <!--HIDDEN--> hidden.
 
'''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.
 
'''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.
  
'''Third line with raw | pipe is handled''', but the space before the pipe is lost. Up to raw 19 pipes are handled, else use <NOWIKI>{{!}}</NOWIKI> and {{!}} it's {{!}} OK.
+
'''Third line with raw | pipe is handled''', but the space before the pipe is lost. Up to raw 19 pipes are handled, else use <nowiki><nowiki></nowiki>{{!}}<nowiki></nowiki></nowiki> and {{!}} it's {{!}} OK.
  
'''Fourth      line,    multiples spaces collapsed into one''' as in HTML and wikitext.
+
'''Fourth      line,    multiple spaces collapsed into one''' as in HTML and wikitext.
 
'''Fifth line, stuck with the previous one''' if no blank line between them.
 
'''Fifth line, stuck with the previous one''' if no blank line between them.
  
Line 54: Line 57:
 
'''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.
 
'''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.
  
'''Third line with raw | pipe is handled''', but the space before the pipe is lost. Up to raw 19 pipes are handled, else use <NOWIKI>{{!}}</NOWIKI> and {{!}} it's {{!}} OK.
+
'''Third line with raw | pipe is handled''', but the space before the pipe is lost. Up to raw 19 pipes are handled, else use <nowiki>{{!}}</nowiki> and {{!}} it's {{!}} OK.
  
'''Fourth      line,    multiples spaces collapsed into one''' as in HTML and wikitext.
+
'''Fourth      line,    multiple spaces collapsed into one''' as in HTML and wikitext.
 
'''Fifth line, stuck with the previous one''' if no blank line between them.
 
'''Fifth line, stuck with the previous one''' if no blank line between them.
  
Line 62: Line 65:
 
}}
 
}}
  
==Alternatives==
+
===See also===
* The [[mw:Extension:ASHighlight|&lt;source&gt; tag]] automatically highlights and bolds source code
+
* {{tl|pre2}}, a template with similar functionality but induces optional line wrap and optional scroll bars.
* The {{[[mw:Help:Magic_words#Formatting|#tag:pre]]}} magic word allows the embeding of varibles{{where}}
+
* {{xtag|syntaxhighlight}}
 
+
* [[HTML element#Other block elements|{{tag|pre|o}}]]
==See also==
 
* {{tl|Pre2}}, for <nowiki><pre></nowiki> either with wrapped text or a scrollbar.
 
* [[HTML element#Other containers|<nowiki><pre>…</pre></nowiki>]], for general information on the tags.
 
 
 
<includeonly><!-- CATEGORIES AND INTERWIKIS HERE, THANKS -->
 
[[Category:Wikipedia formatting and function templates|{{PAGENAME}}]]
 
 
 
  
</includeonly>
+
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox |
 +
| <!-- CATEGORIES BELOW THIS LINE, PLEASE: -->
 +
[[Category:Programming typing-aid templates]]
 +
[[Category:Wikipedia XHTML tag-replacing templates]]
 +
}}</includeonly>

Latest revision as of 06:27, 15 March 2016

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

Usage[edit]

Markup Renders as
[markup]

[rendering]

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>); similarly, multiple spaces are treated as a single one.
  • If there are only two lines, they will be stuck together, even if the source has a blank line between them.

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[edit]

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.

'''Third line with raw | pipe is handled''', but the space before the pipe is lost. Up to raw 19 pipes are handled, else use <nowiki>{{!}}</nowiki> and {{!}} it's {{!}} OK.

'''Fourth      line,     multiple spaces collapsed into one''' as in HTML and wikitext.
'''Fifth line, stuck with the previous one''' if no blank line between them.

'''Last line''', is actually standalone with or without a blank line.
}}
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.

Third line with raw| pipe is handled, but the space before the pipe is lost. Up to raw 19 pipes are handled, else use {{!}} and | it's | OK.

Fourth      line,     multiple spaces collapsed into one as in HTML and wikitext.
Fifth line, stuck with the previous one if no blank line between them.

Last line, is actually standalone with or without a blank line.

See also[edit]

  • {{pre2}}, a template with similar functionality but induces optional line wrap and optional scroll bars.
  • Template:Xtag
  • <pre>