Difference between revisions of "Template:Pre/doc"

From Ava Zinn Wiki
Jump to: navigation, search
[unchecked revision][unchecked revision]
(copy edit)
m (31 revisions from wikipedia:Template:Pre/doc)
 
(9 intermediate revisions by 8 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 -->
__NOTOC____NOEDITSECTION__
+
 
This template mimics the functionality of the [[HTML]] <tt><nowiki><pre></nowiki></tt> tag.
+
This template implements a version of the functionality provided by the [[HTML]] {{tag|pre|o}} tag.
  
 
===Usage===
 
===Usage===
{{Table|row1=<pre>
+
{{markup
{{Pre|
+
|<nowiki>{{Pre|
 +
This Pre-format
 +
 
 +
can look
 +
 
 +
like this.
 +
}}</nowiki>
 +
|{{Pre|
 
This Pre-format
 
This Pre-format
  
Line 13: Line 20:
 
like this.
 
like this.
 
}}
 
}}
</pre>}}
+
}}
 
 
 
Main differences include:
 
Main differences include:
 
 
* It wraps text that overflows the page.
 
* It wraps text that overflows 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 contains 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>, {{tld|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.
+
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>
Line 61: Line 64:
 
'''Last line''', is actually standalone with or without a blank line.
 
'''Last line''', is actually standalone with or without a blank line.
 
}}
 
}}
 
===Alternatives===
 
* The &lt;source&gt; tag extension documented at [[MediaWiki]] [[mw:Extension:ASHighlight|Extension:ASHighlight]].
 
* The &#123;&#123;#tag:}} functionality documented at [[MediaWiki]] [[mw:Help:Magic words|Help:Magic words]].
 
  
 
===See also===
 
===See also===
* {{tl|Pre2}}, a template with similar functionality but induces optional line wrap and optional scroll bars.
+
* {{tl|pre2}}, a template with similar functionality but induces optional line wrap and optional scroll bars.
* [[HTML element#Other containers|<nowiki><pre></nowiki>]], for information about the HTML <nowiki><pre></nowiki> tag.
+
* {{xtag|syntaxhighlight}}
 
+
* [[HTML element#Other block elements|{{tag|pre|o}}]]
<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>