Difference between revisions of "Template:Indent/doc"

From blackwiki
Jump to navigation Jump to search
imported>Nøkkenbuer
m (→‎See also: replaced {{tag}} with {{code}} for syntax highlighting; inserted code HTML around colon)
imported>Nøkkenbuer
m (clarified and wikilinked non-breaking space; added code HTML markup; added {{em}}s and {{code}}; minor punctuation cleanup)
Line 3: Line 3:
 
<!-- PLEASE ADD CATEGORIES WHERE INDICATED AT THE BOTTOM OF THIS PAGE -->
 
<!-- PLEASE ADD CATEGORIES WHERE INDICATED AT THE BOTTOM OF THIS PAGE -->
  
The template {{tlx|indent}} performs a newline and indents by a specified number of spaces. However, the spaces are not all the same size, but rather a mixture of [[en (typography)|en]]-size & [[em (typography)|em]]-size spaces that have been tested to work on a wide range of browsers.  (To skip by {{var|n}} equal-size spaces, instead use {{tl2|in5|{{var|n}}}} which puts all as the standard-size "&nbsp;" space, and does not force a newline.)
+
The template {{tlx|indent}} performs a newline and indents by a specified number of spaces. However, the spaces are not all the same size, but rather a mixture of [[en (typography)|en]]-size & [[em (typography)|em]]-size spaces that have been tested to work on a wide range of browsers.  (To skip by {{var|n}} equal-size spaces, instead use {{tl2|in5|{{var|n}}}}, which puts all as the standard-size [[non-breaking space]] and does not force a newline.)
 
__TOC__
 
__TOC__
  
 
===Usage===
 
===Usage===
The indentation spacing generated by [[Template:Indent]] will match the alignment of a colon-shift (":") by using {{tl2|indent|5}}. To match "::", use {{tl2|indent|10}}.
+
The indentation spacing generated by [[Template:Indent]] will match the alignment of a colon-shift <code>:</code> by using {{tl2|indent|5}}. To match <code>::</code>, use {{tl2|indent|10}}.
 
* Note: This may vary depending on your browser.
 
* Note: This may vary depending on your browser.
  
'''Usage:''' {{tl2|indent|''# of spaces''}}
+
'''Usage:''' {{tl2|indent|{{var|# of spaces}}}}
* Indents up to 30 spaces. (use {{tl2|in5|n}} to skip up to 50 spaces)
+
* Indents up to 30 spaces. (use {{tl2|in5|{{var|n}}}} to skip up to 50 spaces)
 
* Indent differs from {{tl2|space}} only in that it automatically begins a wrapped-newline, then spaces over {{var|n}} spaces, whereas {{tl|space}} spaces over {{var|n}} in the same (current) line.
 
* Indent differs from {{tl2|space}} only in that it automatically begins a wrapped-newline, then spaces over {{var|n}} spaces, whereas {{tl|space}} spaces over {{var|n}} in the same (current) line.
  
 
===Examples===
 
===Examples===
The following are detailed examples, also comparing to the equivalent indentation generated if a colon-shift ":" were used instead.
+
The following are detailed examples, also comparing to the equivalent indentation generated if a colon-shift <code>:</code> were used instead.
  
 
{{markupv|title=Example 1 – ''Indenting by 5:''
 
{{markupv|title=Example 1 – ''Indenting by 5:''
Line 21: Line 21:
 
|renders=Some text.{{indent|5}}Some more text.}}
 
|renders=Some text.{{indent|5}}Some more text.}}
  
{{markupv|title=Example 2 – ''Alignment with ":" or "::" indentations:''
+
{{markupv|title=Example 2 – ''Alignment with <code>:</code> or <code>::</code> indentations:''
  
 
|markup=<nowiki>: Line of colon-shifted text.
 
|markup=<nowiki>: Line of colon-shifted text.
Line 45: Line 45:
 
As computers optimize code, they occasionally risk displaying unsavory results after condensing monotonous strings of characters (such as spaces). Thus, many templates around Wiki choose to avoid this hurdle by alternating different types of spaces (with the intention of displaying no differently than regular spaces).
 
As computers optimize code, they occasionally risk displaying unsavory results after condensing monotonous strings of characters (such as spaces). Thus, many templates around Wiki choose to avoid this hurdle by alternating different types of spaces (with the intention of displaying no differently than regular spaces).
  
Spaces come in two main size varieties: ''[[em (typography)|em spaces]]'' and ''[[en (typography)|en spaces]]''. Em spaces are generally defined as the width of one character, and en spaces exactly half that size. However, there is no requirement that browsers ''must'' conform to this standard, and so templates that code in en spaces ''may'' not display uniformly across all browsers. Neither {{tl|indent}} nor {{tl|space}} use true space-size (that is, em-size spaces), but rather mix en and em spaces, whereas {{tl2|in5|{{var|n}}}} avoids en spaces altogether and will actually skip {{var|n}} count of spaces, as if inserting {{var|n}} repetitions of an em space. This is done by alternating em spaces with an em-size non-breaking <code>"&amp;nbsp;"</code>—by definition, it must be the same—in order to skip a wide area.
+
Spaces come in two main size varieties: ''[[em (typography)|em spaces]]'' and ''[[en (typography)|en spaces]]''. Em spaces are generally defined as the width of one character, and en spaces exactly half that size. However, there is no requirement that browsers {{em|must}} conform to this standard, and so templates that code in en spaces {{em|may}} not display uniformly across all browsers. Neither {{tl|indent}} nor {{tl|space}} use true space-size (that is, em-size spaces), but rather mix en and em spaces, whereas {{tl2|in5|{{var|n}}}} avoids en spaces altogether and will actually skip {{var|n}} count of spaces, as if inserting {{var|n}} repetitions of an em space. This is done by alternating em spaces with an em-size non-breaking {{code|lang=html|code=&nbsp;}}—by definition, it must be the same—in order to skip a wide area.
  
 
===History===
 
===History===
This template originated on the [[Wikipedia:Sister projects|sister project]] '''[[Wikisource]]'''&mdash;[[Wikisource:Main Page|(main page)]], and was subsequently ported to English Wikipedia at 21:27, 26 May 2006 (UTC).
+
This template originated on the [[Wikipedia:Sister projects|sister project]] '''[[Wikisource]]''' ([[Wikisource:Main Page|main page]]), and was subsequently ported to English Wikipedia at 21:27, 26 May 2006 (UTC).
  
 
===See also===
 
===See also===

Revision as of 22:50, 9 June 2018

The template {{indent}} performs a newline and indents by a specified number of spaces. However, the spaces are not all the same size, but rather a mixture of en-size & em-size spaces that have been tested to work on a wide range of browsers. (To skip by n equal-size spaces, instead use {{in5|n}}, which puts all as the standard-size non-breaking space and does not force a newline.)

Usage

The indentation spacing generated by Template:Indent will match the alignment of a colon-shift : by using {{indent|5}}. To match ::, use {{indent|10}}.

  • Note: This may vary depending on your browser.

Usage: {{indent|# of spaces}}

  • Indents up to 30 spaces. (use {{in5|n}} to skip up to 50 spaces)
  • Indent differs from {{space}} only in that it automatically begins a wrapped-newline, then spaces over n spaces, whereas {{space}} spaces over n in the same (current) line.

Examples

The following are detailed examples, also comparing to the equivalent indentation generated if a colon-shift : were used instead.

Example 1 – Indenting by 5:
Markup
Some text.{{indent|5}}Some more text.
Renders as Some text.
     Some more text.
Example 2 – Alignment with : or :: indentations:
Markup
: Line of colon-shifted text.
{{indent|5}}Line of indent-5-shifted text.
<br>      Line of br-6-nbsp-shifted text.
<br>     Line of br-5-nbsp-shifted text.
<br>     Line of br-5-nbsp-true-shifted text.
:: Line of 2-colon-shifted text.
{{space|10}}Line of space-10-shifted text.
Renders as : Line of colon-shifted text.


     Line of indent-5-shifted text.
      Line of br-6-nbsp-shifted text.
     Line of br-5-nbsp-shifted text.
     Line of br-5-nbsp-true-shifted text.

Line of 2-colon-shifted text.

Template:SpaceLine of space-10-shifted text.

Note that if the prior line is already colon-shifted text, then using "{{indent|5}}" generates a blank line first, so instead, use "{{space|5}}" (or such) after a colon-shifted line.

Analysis of uneven spacing

As computers optimize code, they occasionally risk displaying unsavory results after condensing monotonous strings of characters (such as spaces). Thus, many templates around Wiki choose to avoid this hurdle by alternating different types of spaces (with the intention of displaying no differently than regular spaces).

Spaces come in two main size varieties: em spaces and en spaces. Em spaces are generally defined as the width of one character, and en spaces exactly half that size. However, there is no requirement that browsers must conform to this standard, and so templates that code in en spaces may not display uniformly across all browsers. Neither {{indent}} nor {{space}} use true space-size (that is, em-size spaces), but rather mix en and em spaces, whereas {{in5|n}} avoids en spaces altogether and will actually skip n count of spaces, as if inserting n repetitions of an em space. This is done by alternating em spaces with an em-size non-breaking &nbsp;—by definition, it must be the same—in order to skip a wide area.

History

This template originated on the sister project Wikisource (main page), and was subsequently ported to English Wikipedia at 21:27, 26 May 2006 (UTC).

See also

  • Module:Indent, the Lua module implementing this template.
  • {{spaces}}, which uses non-breaking spaces.
  • {{in5}}, which skips up to fifty equal en-sized spaces.
  • {{block indent}}, to indent an entire block of content, similar to a block quotation (uses <div> and CSS margins)
  • {{colon}}, to produce a colon character (:) without risk of affecting wiki markup.
  • {{outdent}}, to break indentation in a threaded conversation