Difference between revisions of "Template:Spaced en dash/doc"

From Timelines
Jump to: navigation, search
(`also ridiculous -- fix the tooltip machinery -- no one's seriously suggesting there should be no templates used in leads)
(Incorrect usage: why all thsi elaborate detailing of what happens if you use it wrong? Is someone planning to use it wrong?)
Line 25: Line 25:
 
| <p>Normally, in a real box these items would be links, but this is an example.</p> Item1{{spaced ndash}} A{{spaced ndash}} B{{spaced ndash}} Item2{{spaced ndash}} Item3{{spaced ndash}} Item4{{spaced ndash}} Item5{{spaced ndash}} extra item{{spaced ndash}} E{{spaced ndash}} 1{{spaced ndash}} 2{{spaced ndash}} 3{{spaced ndash}} 4{{spaced ndash}} 5{{spaced ndash}} 6{{spaced ndash}} 7{{spaced ndash}} {{nowrap|item that won't attach to prior line unless it fits in the remaining space{{spaced ndash}}}} Q{{spaced ndash}} A slightly longer item{{spaced ndash}} KK{{spaced ndash}} An obviously really even longer item that the dash will hang at its end{{spaced ndash}} Item6{{spaced ndash}} C{{spaced ndash}} Item7{{spaced ndash}} Item8{{spaced ndash}} Item9{{spaced ndash}} Item10{{spaced ndash}} Item11{{spaced ndash}} Item12{{spaced ndash}} D{{spaced ndash}} Item13{{spaced ndash}} Item14{{spaced ndash}} Item15{{spaced ndash}} Item16{{spaced ndash}} Item17{{spaced ndash}} Item18 <p>The space on the end makes sure the dash doesn't touch the edge of the box, either</p>
 
| <p>Normally, in a real box these items would be links, but this is an example.</p> Item1{{spaced ndash}} A{{spaced ndash}} B{{spaced ndash}} Item2{{spaced ndash}} Item3{{spaced ndash}} Item4{{spaced ndash}} Item5{{spaced ndash}} extra item{{spaced ndash}} E{{spaced ndash}} 1{{spaced ndash}} 2{{spaced ndash}} 3{{spaced ndash}} 4{{spaced ndash}} 5{{spaced ndash}} 6{{spaced ndash}} 7{{spaced ndash}} {{nowrap|item that won't attach to prior line unless it fits in the remaining space{{spaced ndash}}}} Q{{spaced ndash}} A slightly longer item{{spaced ndash}} KK{{spaced ndash}} An obviously really even longer item that the dash will hang at its end{{spaced ndash}} Item6{{spaced ndash}} C{{spaced ndash}} Item7{{spaced ndash}} Item8{{spaced ndash}} Item9{{spaced ndash}} Item10{{spaced ndash}} Item11{{spaced ndash}} Item12{{spaced ndash}} D{{spaced ndash}} Item13{{spaced ndash}} Item14{{spaced ndash}} Item15{{spaced ndash}} Item16{{spaced ndash}} Item17{{spaced ndash}} Item18 <p>The space on the end makes sure the dash doesn't touch the edge of the box, either</p>
 
|}
 
|}
 
== Incorrect usage ==
 
 
If the template is used slightly wrong it will in some cases still behave well. For instance if there are no or several spaces after the template. Like these examples:
 
 
<nowiki>[[Salt]]{{spaced ndash}}[[Pepper]]</nowiki>
 
<nowiki>[[Salt]]{{spaced ndash}}  [[Pepper]]</nowiki>
 
 
Both of them will render exactly as before, with just one space on each side of the dash, like this:
 
:[[Salt]] &ndash; [[Black pepper|Pepper]]
 
 
And it will still only line break ''after'' a dash, like this:
 
:[[Salt]] &ndash;
 
:[[Black pepper|Pepper]]
 
 
But putting one or more spaces ''before'' the template will cause problems, like these examples:
 
<nowiki>[[Salt]] {{spaced ndash}}[[Pepper]]</nowiki>
 
<nowiki>[[Salt]]  {{spaced ndash}}[[Pepper]]</nowiki>
 
<nowiki>[[Salt]] {{spaced ndash}} [[Pepper]]</nowiki>
 
<nowiki>[[Salt]]  {{spaced ndash}}  [[Pepper]]</nowiki>
 
 
Then it will render with ''two'' spaces before the dash, and one after, like this:
 
:[[Salt]] &nbsp;&ndash; [[Black pepper|Pepper]]
 
 
And if it line breaks it might break ''before'' the dash, like this:
 
:[[Salt]]
 
:&nbsp;&ndash; [[Black pepper|Pepper]]
 
  
 
== Technical details ==
 
== Technical details ==

Revision as of 07:27, 29 March 2015

This is the spaced ndash template; it looks like this " – ".

It works similarly to the HTML markup sequence "&nbsp;&ndash; ". That is, a non-breaking space, a short dash (known as an en dash) and a normal space.

This template may be used:

  • in prose as an alternative to the em dash, provided that each article is consistent in using either unspaced em dashes or spaced en dashes (see WP:EMDASH)
  • in ranges where at least one end point contains a space, for example, 15 July{{snd}} 7 August or 9 a.m.{{snd}} 5 p.m., but not 18{{snd}} 20 September or 2007{{snd}} 2008 as the latter two examples require an unspaced en dash (see WP:ENDASH).
  • in lists when you want something stronger than a bold middot "·" or a bullet "•", but shorter than an em dash "—" (an en dash is half the width of an em dash). For horizontal lists, use {{flatlist}} or class="hlist" instead (see WP:HLIST) Here, the recommended usage is to use no space before the template and one space after the template, like this:
[[Salt]]{{spaced ndash}} [[Pepper]]
This will render one space on each side of the dash, like this:
SaltPepper
A line break will come after one of the dashes, not before, when the spacing is used as suggested, like this:
SaltPepper
CurrySaffron
Here's an example of use for lists
One use of template "Spaced ndash" is within other templates, tables, lists, and similar things to provide a separator between items. It is also to be consistent so that the article editor can use their choice of {{bull}}, {{dot}}, {{middot}}, or {{spaced ndash}} and not have to insert the  • ,  · ,  · , or Template:Spaced ndash symbol, they can use any of these as a simple macro. The idea being that if you have a table with a list of items, you can insert a spaced short dash (or the other symbols) between items that will appear correct, in that the items always have just one separator between them, and when a list crawls to the next line, the dash hangs onto the prior item instead of rolling over to the next line. Notice on the end of this box, the symbol hangs on the end of the last item that will fit on the line indicating that additional items follow on the next line as part of this list, but the item only stays on the line if the item and the dash will fit. See the column on the right. In code it is Item1{{spaced ndash}} Item2{{spaced ndash}} Item3{{spaced ndash}} Item4{{spaced ndash}} Item5{{spaced ndash}} etc. (with some smaller items squeezed in to show that the list does not have to be the same number of items per line) but in the box they all fold perfectly once it runs out of space on the line to fit the next item and the dash following.

Normally, in a real box these items would be links, but this is an example.

Item1Template:Spaced ndash ATemplate:Spaced ndash BTemplate:Spaced ndash Item2Template:Spaced ndash Item3Template:Spaced ndash Item4Template:Spaced ndash Item5Template:Spaced ndash extra itemTemplate:Spaced ndash ETemplate:Spaced ndash 1Template:Spaced ndash 2Template:Spaced ndash 3Template:Spaced ndash 4Template:Spaced ndash 5Template:Spaced ndash 6Template:Spaced ndash 7Template:Spaced ndash item that won't attach to prior line unless it fits in the remaining spaceTemplate:Spaced ndash QTemplate:Spaced ndash A slightly longer itemTemplate:Spaced ndash KKTemplate:Spaced ndash An obviously really even longer item that the dash will hang at its endTemplate:Spaced ndash Item6Template:Spaced ndash CTemplate:Spaced ndash Item7Template:Spaced ndash Item8Template:Spaced ndash Item9Template:Spaced ndash Item10Template:Spaced ndash Item11Template:Spaced ndash Item12Template:Spaced ndash DTemplate:Spaced ndash Item13Template:Spaced ndash Item14Template:Spaced ndash Item15Template:Spaced ndash Item16Template:Spaced ndash Item17Template:Spaced ndash Item18

The space on the end makes sure the dash doesn't touch the edge of the box, either

Technical details

The space before the dash is a non-breaking space. That means it will not line break and will not collapse together with normal spaces that come before the template.

The space after the dash is a normal space. That means it wraps (allows line breaks) and it will collapse together with normal spaces that come after the template to form one single space.

Dot sizes

· middot
· bold {{middot}}
small bullet
{{bullet}}
bold bullet
{{en dash}}
{{em dash}}

See also

  • {{·}}, which produces a spaced bold interpunct ("middot"): " · "
  • {{•}}, which produces a spaced bullet-point: " • "
  • {{\}}, which produces a spaced (forward-)slash: " / "
  • {{ndash}}, which produces an (unspaced) en dash.
  • {{mdash}}, which produces an (unspaced) em dash.