Template:Dash/doc: Difference between revisions

ArrowHead294 (talk | contribs)
mNo edit summary
ArrowHead294 (talk | contribs)
mNo edit summary
 
(10 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>&amp;mdash;</code> or <code>&amp;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 21: Line 21:


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.
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>&amp;#44;</code>.


=== Usage ===
=== Usage ===
Line 27: 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"
|-
! You type !! You get
! You type !! You get
|-
|-
| <code>s{{=}}</code> || rowspan="2" | Regular space
| <code><nowiki>s=</nowiki></code> || rowspan="2" | Regular space
|-
|-
| <code>s{{=}}space</code>
| <code><nowiki>s=space</nowiki></code>
|-
|-
| <code>s{{=}}thin</code> || Thin space (U+2009 <span style="font-size: 10px;">THIN SPACE</span>)
| <code><nowiki>s=thin</nowiki></code> || Thin space (U+2009 <span style="font-size: 10px;">THIN SPACE</span>)
|-
|-
| <code>s{{=}}hair</code> || Hair space (U+200A <span style="font-size: 10px;">HAIR SPACE</span>)
| <code><nowiki>s=hair</nowiki></code> || Hair space (U+200A <span style="font-size: 10px;">HAIR SPACE</span>)
|-
|-
| <code>s{{=}}nbsp</code> || Non-breaking space (U+00A0 <span style="font-size: 10px;">NO-BREAK SPACE</span>)
| <code><nowiki>s=nbsp</nowiki></code> || Non-breaking space (U+00A0 <span style="font-size: 10px;">NO-BREAK SPACE</span>)
|-
|-
| <code>s{{=}}nnbsp</code> || Narrow non-breaking space (U+202F <span style="font-size: 10px;">NARROW NO-BREAK SPACE</span>)
| <code><nowiki>s=nnbsp</nowiki></code> || Narrow non-breaking space (U+202F <span style="font-size: 10px;">NARROW NO-BREAK SPACE</span>)
|}
|}


Line 45: Line 49:


{| class="wikitable center-all"
{| class="wikitable center-all"
|-
! You type !! You get
! You type !! You get
|-
|-
| <code>d{{=}}</code> || rowspan="2" | Regular hyphen (U+002D - <span style="font-size: 10px;">HYPHEN-MINUS</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> || Em dash (U+2014 &mdash; <span style="font-size: 10px;">EM DASH</span>)
| <code><nowiki>d=long</nowiki></code> || Em dash (U+2014 &mdash; <span style="font-size: 10px;">EM DASH</span>)
|-
|-
| <code>d{{=}}med</code> || En dash (U+2013 &ndash; <span style="font-size: 10px;">EN DASH</span>)
| <code><nowiki>d=med</nowiki></code> || En dash (U+2013 &ndash; <span style="font-size: 10px;">EN DASH</span>)
|-
|-
| <code>d{{=}}larr</code> || Left arrow (U+2190 &larr; <span style="font-size: 10px;">LEFTWARDS ARROW</span>)
| <code><nowiki>d=larr</nowiki></code> || Left arrow (U+2190 &larr; <span style="font-size: 10px;">LEFTWARDS ARROW</span>)
|-
|-
| <code>d{{=}}rarr</code> || Right arrow (U+2192 &rarr; <span style="font-size: 10px;">RIGHTWARDS ARROW</span>)
| <code><nowiki>d=rarr</nowiki></code> || Right arrow (U+2192 &rarr; <span style="font-size: 10px;">RIGHTWARDS ARROW</span>)
|}
|}


Line 63: Line 68:
There are two special cases that are supported, in the case of chains of intervals:
There are two special cases that are supported, in the case of chains of intervals:


; <code>d{{=}}iarr</code>
; <code><nowiki>d=iarr</nowiki></code>
: Sets the primary separator to the right arrow (<code>&rarr;</code>) and the secondary separator to the left arrow (<code>&larr;</code>).
: Sets the primary separator to the right arrow (<code>&rarr;</code>) and the secondary separator to the left arrow (<code>&larr;</code>).


; <code>d{{=}}oarr</code>
; <code><nowiki>d=oarr</nowiki></code>
: Sets the primary separator to the left arrow (<code>&larr;</code>) and the secondary separator to the right arrow (<code>&rarr;</code>).
: Sets the primary separator to the left arrow (<code>&larr;</code>) and the secondary separator to the right arrow (<code>&rarr;</code>).


=== Examples ===
=== Examples ===
{| class="wikitable center-all"
{| class="wikitable center-all"
|-
! You type !! You get
! You type !! You get
|-
|-
| <code>{{((}}dash{{pipe}}A, B, C, D, E, F, G, H{{pipe}}s=space{{pipe}}d=long{{))}}</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=space|d=long}}</nowiki></code> || {{{{ROOTPAGENAME}}|A, B, C, D, E, F, G, H|s=space|d=long}}
|-
|-
| <code>{{((}}dash{{pipe}}A, B, C, D, E, F, G, H{{pipe}}s=thin{{pipe}}d=long{{))}}</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=thin|d=long}}</nowiki></code> || {{{{ROOTPAGENAME}}|A, B, C, D, E, F, G, H|s=thin|d=long}}
|-
|-
| <code>{{((}}dash{{pipe}}A, B, C, D, E, F, G, H{{pipe}}s=hair{{pipe}}d=long{{))}}</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=hair|d=long}}</nowiki></code> || {{{{ROOTPAGENAME}}|A, B, C, D, E, F, G, H|s=hair|d=long}}
|-
|-
| <code>{{((}}dash{{pipe}}A, B, C, D, E, F, G, H{{pipe}}s=space{{pipe}}d=med{{))}}</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=space|d=med}}</nowiki></code> || {{{{ROOTPAGENAME}}|A, B, C, D, E, F, G, H|s=space|d=medium}}
|-
|-
| <code>{{((}}dash{{pipe}}A, B, C, D, E, F, G, H{{pipe}}s=thin{{pipe}}d=med{{))}}</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=thin|d=med}}</nowiki></code> || {{{{ROOTPAGENAME}}|A, B, C, D, E, F, G, H|s=thin|d=medium}}
|-
|-
| <code>{{((}}dash{{pipe}}A, B, C, D, E, F, G, H{{pipe}}s=hair{{pipe}}d=med{{))}}</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=hair|d=med}}</nowiki></code> || {{{{ROOTPAGENAME}}|A, B, C, D, E, F, G, H|s=hair|d=medium}}
|-
|-
| <code>{{((}}dash{{pipe}}A, B, C, D, E, F, G, H{{pipe}}s=space{{pipe}}d={{))}}</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=space|d=}}</nowiki></code> || {{{{ROOTPAGENAME}}|A, B, C, D, E, F, G, H|s=space|d=}}
|-
|-
| <code>{{((}}dash{{pipe}}A, B, C, D, E, F, G, H{{pipe}}s=thin{{pipe}}d={{))}}</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=thin|d=}}</nowiki></code> || {{{{ROOTPAGENAME}}|A, B, C, D, E, F, G, H|s=thin|d=}}
|-
|-
| <code>{{((}}dash{{pipe}}A, B, C, D, E, F, G, H{{pipe}}s=hair{{pipe}}d={{))}}</code> || {{{{ROOTPAGENAME}}|A, B, C, D, E, F, G, H|s=hair|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>{{((}}dash{{pipe}}F, C, G, D, A,, E,, B,, F&#x266F;{{pipe}}s=hair{{pipe}}d=iarr{{))}}</code> || {{{{ROOTPAGENAME}}|F, C, G, D, A,, E,, B,, F&#x266F;|s=hair|d=iarr}}
| <code><nowiki>{{dash|F, C, G, D, A,, E,, B,, F&#x266F;|s=hair|d=iarr}}</nowiki></code> || {{{{ROOTPAGENAME}}|F, C, G, D, A,, E,, B,, F&#x266F;|s=hair|d=iarr}}
|-
|-
| <code>{{((}}dash{{pipe}}F, C, G, D, A,, E,, B,, F&#x266F;{{pipe}}s=hair{{pipe}}d=oarr{{))}}</code> || {{{{ROOTPAGENAME}}|F, C, G, D, A,, E,, B,, F&#x266F;|s=hair|d=oarr}}
| <code><nowiki>{{dash|F, C, G, D, A,, E,, B,, F&#x266F;|s=hair|d=oarr}}</nowiki></code> || {{{{ROOTPAGENAME}}|F, C, G, D, A,, E,, B,, F&#x266F;|s=hair|d=oarr}}
|}
|}
=== See also ===
* {{modlink}}