Template:Dash/doc: Difference between revisions
ArrowHead294 (talk | contribs) No edit summary |
ArrowHead294 (talk | contribs) mNo edit summary |
||
(24 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{dochead}} | {{dochead}}{{substitute|no}}{{clear}}{{lua}} | ||
This template converts a sequence separated by commas and spaces into one separated by dashes. | This template is designed to illustrate chains of intervals (fifths especially) without having to manually type out the entities such as <code>&mdash;</code> or <code>&ndash;</code>. It also allows the insertion of spaces in between the dashes and elements in order to reduce clutter. It converts a sequence separated by commas and spaces into one separated by dashes. | ||
=== Parameters === | === Parameters === | ||
; <code>{{{1}}}</code> | ; <code><nowiki>{{{1}}}</nowiki></code> | ||
: Accepts one unnamed parameter, which is the list to be converted. | : Accepts one unnamed parameter, which is the list to be converted. | ||
Line 10: | Line 10: | ||
; <code>d</code> | ; <code>d</code> | ||
: Specifies what dash to use, with options for short, medium, and long dashes. | : Specifies what dash to use, with options for short, medium, and long dashes, plus left and right arrows. | ||
; <code>d2</code> | |||
: Second separator for bidirectional lists. | |||
'''Note:''' If you pass in all unnamed parameters, the second will be used to determine the dash instead of the space if only two parameters are invoked. If three or four are specified, the second parameter will determine the space while the third (and fourth, if passed) will determine the dash. | |||
==== Dual separators ==== | |||
This template currently has options for two different separators. | |||
For the primary separator, separate items by <code>,</code> followed by one or more spaces (if no secondary separator is specified, any combination of commas and whitespaces of any length will be treated as a single separator, as long as it ends in one or more whitespaces). An additional separator can be invoked by separating items using two commas (<code>,,</code>) followed by one or more spaces. | |||
==== Commas ==== | |||
'''Note:''' Comma characters that are not part of a separator must be escaped as <code>&#44;</code>. | |||
=== Usage === | === Usage === | ||
Line 17: | Line 30: | ||
To adjust spacing between list elements and dashes, use the <code>spaces</code> parameter (defaults to the regular space character). | To adjust spacing between list elements and dashes, use the <code>spaces</code> parameter (defaults to the regular space character). | ||
{| class="wikitable center-all" | {| class="wikitable center-all" | ||
|- | |- | ||
| <code>s=</code> | ! You type !! You get | ||
| rowspan="2" | Regular space | |- | ||
| <code><nowiki>s=</nowiki></code> || rowspan="2" | Regular space | |||
|- | |||
| <code><nowiki>s=space</nowiki></code> | |||
|- | |||
| <code><nowiki>s=thin</nowiki></code> || Thin space (U+2009 <span style="font-size: 10px;">THIN SPACE</span>) | |||
|- | |- | ||
| <code>s=space</ | | <code><nowiki>s=hair</nowiki></code> || Hair space (U+200A <span style="font-size: 10px;">HAIR SPACE</span>) | ||
|- | |- | ||
| <code>s= | | <code><nowiki>s=nbsp</nowiki></code> || Non-breaking space (U+00A0 <span style="font-size: 10px;">NO-BREAK SPACE</span>) | ||
| | |||
|- | |- | ||
| <code>s= | | <code><nowiki>s=nnbsp</nowiki></code> || Narrow non-breaking space (U+202F <span style="font-size: 10px;">NARROW NO-BREAK SPACE</span>) | ||
| | |||
|} | |} | ||
Line 35: | Line 49: | ||
{| class="wikitable center-all" | {| class="wikitable center-all" | ||
|- | |- | ||
| <code>d=</code> | ! You type !! You get | ||
| rowspan="2" | <span> | |- | ||
| <code><nowiki>d=</nowiki></code> || rowspan="2" | Regular hyphen (U+002D - <span style="font-size: 10px;">HYPHEN-MINUS</span>) | |||
|- | |- | ||
| <code>d=short</code> | | <code><nowiki>d=short</nowiki></code> | ||
|- | |- | ||
| <code>d=long</code> | | <code><nowiki>d=long</nowiki></code> || Em dash (U+2014 — <span style="font-size: 10px;">EM DASH</span>) | ||
| Em dash (U+2014 — <span style="font-size: 10px;">EM DASH</span>) | |||
|- | |- | ||
| <code>d=med</code> | | <code><nowiki>d=med</nowiki></code> || En dash (U+2013 – <span style="font-size: 10px;">EN DASH</span>) | ||
| En dash (U+2013 – <span style="font-size: 10px;">EN DASH</span>) | |||
|- | |- | ||
| <code>d=larr</code> | | <code><nowiki>d=larr</nowiki></code> || Left arrow (U+2190 ← <span style="font-size: 10px;">LEFTWARDS ARROW</span>) | ||
| Left arrow (U+2190 ← <span style="font-size: 10px;">LEFTWARDS ARROW</span>) | |||
|- | |- | ||
| <code>d=rarr</code> | | <code><nowiki>d=rarr</nowiki></code> || Right arrow (U+2192 → <span style="font-size: 10px;">RIGHTWARDS ARROW</span>) | ||
| Right arrow (U+2192 → <span style="font-size: 10px;">RIGHTWARDS ARROW</span>) | |||
|} | |} | ||
==== Bidirectional arrows ==== | |||
There are two special cases that are supported, in the case of chains of intervals: | |||
; <code><nowiki>d=iarr</nowiki></code> | |||
: Sets the primary separator to the right arrow (<code>→</code>) and the secondary separator to the left arrow (<code>←</code>). | |||
; <code><nowiki>d=oarr</nowiki></code> | |||
: Sets the primary separator to the left arrow (<code>←</code>) and the secondary separator to the right arrow (<code>→</code>). | |||
=== Examples === | === Examples === | ||
{| class="wikitable center-all" | {| class="wikitable center-all" | ||
|- | |- | ||
| < | ! You type !! You get | ||
| {{dash|A, B, C, D, E, F, G, H|s= | |- | ||
| <code><nowiki>{{dash|A, B, C, D, E, F, G, H|s=space|d=long}}</nowiki></code> || {{{{ROOTPAGENAME}}|A, B, C, D, E, F, G, H|s=space|d=long}} | |||
|- | |||
| <code><nowiki>{{dash|A, B, C, D, E, F, G, H|s=thin|d=long}}</nowiki></code> || {{{{ROOTPAGENAME}}|A, B, C, D, E, F, G, H|s=thin|d=long}} | |||
|- | |||
| <code><nowiki>{{dash|A, B, C, D, E, F, G, H|s=hair|d=long}}</nowiki></code> || {{{{ROOTPAGENAME}}|A, B, C, D, E, F, G, H|s=hair|d=long}} | |||
|- | |- | ||
| < | | <code><nowiki>{{dash|A, B, C, D, E, F, G, H|s=space|d=med}}</nowiki></code> || {{{{ROOTPAGENAME}}|A, B, C, D, E, F, G, H|s=space|d=medium}} | ||
| {{ | |||
|- | |- | ||
| < | | <code><nowiki>{{dash|A, B, C, D, E, F, G, H|s=thin|d=med}}</nowiki></code> || {{{{ROOTPAGENAME}}|A, B, C, D, E, F, G, H|s=thin|d=medium}} | ||
| {{ | |||
|- | |- | ||
| < | | <code><nowiki>{{dash|A, B, C, D, E, F, G, H|s=hair|d=med}}</nowiki></code> || {{{{ROOTPAGENAME}}|A, B, C, D, E, F, G, H|s=hair|d=medium}} | ||
| {{ | |||
|- | |- | ||
| < | | <code><nowiki>{{dash|A, B, C, D, E, F, G, H|s=space|d=}}</nowiki></code> || {{{{ROOTPAGENAME}}|A, B, C, D, E, F, G, H|s=space|d=}} | ||
| {{ | |||
|- | |- | ||
| < | | <code><nowiki>{{dash|A, B, C, D, E, F, G, H|s=thin|d=}}</nowiki></code> || {{{{ROOTPAGENAME}}|A, B, C, D, E, F, G, H|s=thin|d=}} | ||
| {{ | |||
|- | |- | ||
| < | | <code><nowiki>{{dash|A, B, C, D, E, F, G, H|s=hair|d=}}</nowiki></code> || {{{{ROOTPAGENAME}}|A, B, C, D, E, F, G, H|s=hair|d=}} | ||
| {{ | |||
|- | |- | ||
| < | | <code><nowiki>{{dash|F, C, G, D, A,, E,, B,, F♯|s=hair|d=iarr}}</nowiki></code> || {{{{ROOTPAGENAME}}|F, C, G, D, A,, E,, B,, F♯|s=hair|d=iarr}} | ||
| {{ | |||
|- | |- | ||
| < | | <code><nowiki>{{dash|F, C, G, D, A,, E,, B,, F♯|s=hair|d=oarr}}</nowiki></code> || {{{{ROOTPAGENAME}}|F, C, G, D, A,, E,, B,, F♯|s=hair|d=oarr}} | ||
| {{ | |||
|} | |} | ||