Template:Gaps/doc

From Embroidery Machine WIKI
< Template:Gaps
Revision as of 16:08, 30 July 2013 by TheEmbroideryWarehouse (talk | contribs) (1 revision)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

{{#ifeq:doc |doc

    | 

{{#ifeq:show |show

         | {{
 {{#invoke:Namespace detect|main}}

| type = notice | image = File:Edit-copy green.svg | imageright = | class = | style = margin-bottom:1.0em; | textstyle = | text = This is a documentation subpage for Template:Gaps.
It contains usage information, categories and other content that is not part of the original {{#if: |{{{text2}}} |{{#if: |{{{text1}}} |{{#ifeq:Template |User |template template page |{{#if:Template |template page|article}}}}}}}}. | small = | smallimage = | smallimageright = | smalltext = | subst = | date = | name = }}

        }}{{#if: |
         |   {{#ifexist:Template:Gaps
                  | [[Category:{{#switch:Template |Template=Template |Module=Module |User=User |#default=Wikipedia}} documentation pages]]
                  |
                 }}
        }}
    | 
   }}

Template:Gaps outputs its unnamed arguments in order, applying the margin-left: 0.25em CSS rule to all but the first, so that there will be gaps of 0.25em between the arguments. The whole output has the white-space: nowrap rule so that it will not be broken across several lines.

It supports up to twenty unnamed arguments. In addition, it supports the base and e arguments which can be used for numbers in exponential notation. The base will be assumed to be 10 unless otherwise specified; a hyphen-minus "-" in the exponent will be automatically substituted by a minus sign "−". It also supports the arguments lhs and u for putting left-hand sides and units within the non-breaking span (see examples below).

See Wikipedia:Manual of Style (dates and numbers)#Large numbers and Wikipedia:Manual of Style (dates and numbers)#Decimal points for information about where to put the gaps in numbers.

Usage

Input Output
{{gaps|−2.002|319|304|3622(15)}} {{{lhs}}} = }}−2.002{{#if:319|319}}{{#if:304|304}}{{#if:3622(15)|3622(15)}}{{#if:|{{{5}}}}}{{#if:|{{{6}}}}}{{#if:|{{{7}}}}}{{#if:|{{{8}}}}}{{#if:|{{{9}}}}}{{#if:|{{{10}}}}}{{#if:|{{{11}}}}}{{#if:|{{{12}}}}}{{#if:|{{{13}}}}}{{#if:|{{{14}}}}}{{#if:|{{{15}}}}}{{#if:|{{{16}}}}}{{#if:|{{{17}}}}}{{#if:|{{{18}}}}}{{#if:|{{{19}}}}}{{#if:|{{{20}}}}}{{#if:|×10^{{#ifeq:{{#expr:{{{e}}}<0}}|1|−{{#expr:-{{{e}}}}}|{{{e}}}}}}}{{#if:| {{{u}}}}}
{{gaps|299|792|458|u=m/s}} {{{lhs}}} = }}299{{#if:792|792}}{{#if:458|458}}{{#if:|{{{4}}}}}{{#if:|{{{5}}}}}{{#if:|{{{6}}}}}{{#if:|{{{7}}}}}{{#if:|{{{8}}}}}{{#if:|{{{9}}}}}{{#if:|{{{10}}}}}{{#if:|{{{11}}}}}{{#if:|{{{12}}}}}{{#if:|{{{13}}}}}{{#if:|{{{14}}}}}{{#if:|{{{15}}}}}{{#if:|{{{16}}}}}{{#if:|{{{17}}}}}{{#if:|{{{18}}}}}{{#if:|{{{19}}}}}{{#if:|{{{20}}}}}{{#if:|×10^{{#ifeq:{{#expr:{{{e}}}<0}}|1|−{{#expr:-{{{e}}}}}|{{{e}}}}}}}{{#if:m/s| m/s}}
{{gaps|lhs=π|3.14159|26535|89793|23846|26433|83279|...}} π = }}3.14159{{#if:26535|26535}}{{#if:89793|89793}}{{#if:23846|23846}}{{#if:26433|26433}}{{#if:83279|83279}}{{#if:...|...}}{{#if:|{{{8}}}}}{{#if:|{{{9}}}}}{{#if:|{{{10}}}}}{{#if:|{{{11}}}}}{{#if:|{{{12}}}}}{{#if:|{{{13}}}}}{{#if:|{{{14}}}}}{{#if:|{{{15}}}}}{{#if:|{{{16}}}}}{{#if:|{{{17}}}}}{{#if:|{{{18}}}}}{{#if:|{{{19}}}}}{{#if:|{{{20}}}}}{{#if:|×10^{{#ifeq:{{#expr:{{{e}}}<0}}|1|−{{#expr:-{{{e}}}}}|{{{e}}}}}}}{{#if:| {{{u}}}}}
{{gaps|P.|A.|M.}} Dirac {{{lhs}}} = }}P.{{#if:A.|A.}}{{#if:M.|M.}}{{#if:|{{{4}}}}}{{#if:|{{{5}}}}}{{#if:|{{{6}}}}}{{#if:|{{{7}}}}}{{#if:|{{{8}}}}}{{#if:|{{{9}}}}}{{#if:|{{{10}}}}}{{#if:|{{{11}}}}}{{#if:|{{{12}}}}}{{#if:|{{{13}}}}}{{#if:|{{{14}}}}}{{#if:|{{{15}}}}}{{#if:|{{{16}}}}}{{#if:|{{{17}}}}}{{#if:|{{{18}}}}}{{#if:|{{{19}}}}}{{#if:|{{{20}}}}}{{#if:|×10^{{#ifeq:{{#expr:{{{e}}}<0}}|1|−{{#expr:-{{{e}}}}}|{{{e}}}}}}}{{#if:| {{{u}}}}} Dirac
{{nowrap|1={{gaps|sin|2''φ''}} = 2 {{gaps|sin|''φ''}} {{gaps|cos|''φ''}}}} {{{lhs}}} = }}sin{{#if:2φ|2φ}}{{#if:|{{{3}}}}}{{#if:|{{{4}}}}}{{#if:|{{{5}}}}}{{#if:|{{{6}}}}}{{#if:|{{{7}}}}}{{#if:|{{{8}}}}}{{#if:|{{{9}}}}}{{#if:|{{{10}}}}}{{#if:|{{{11}}}}}{{#if:|{{{12}}}}}{{#if:|{{{13}}}}}{{#if:|{{{14}}}}}{{#if:|{{{15}}}}}{{#if:|{{{16}}}}}{{#if:|{{{17}}}}}{{#if:|{{{18}}}}}{{#if:|{{{19}}}}}{{#if:|{{{20}}}}}{{#if:|×10^{{#ifeq:{{#expr:{{{e}}}<0}}|1|−{{#expr:-{{{e}}}}}|{{{e}}}}}}}{{#if:| {{{u}}}}} = 2 {{#if:|{{{lhs}}} = }}sin{{#if:φ|φ}}{{#if:|{{{3}}}}}{{#if:|{{{4}}}}}{{#if:|{{{5}}}}}{{#if:|{{{6}}}}}{{#if:|{{{7}}}}}{{#if:|{{{8}}}}}{{#if:|{{{9}}}}}{{#if:|{{{10}}}}}{{#if:|{{{11}}}}}{{#if:|{{{12}}}}}{{#if:|{{{13}}}}}{{#if:|{{{14}}}}}{{#if:|{{{15}}}}}{{#if:|{{{16}}}}}{{#if:|{{{17}}}}}{{#if:|{{{18}}}}}{{#if:|{{{19}}}}}{{#if:|{{{20}}}}}{{#if:|×10^{{#ifeq:{{#expr:{{{e}}}<0}}|1|−{{#expr:-{{{e}}}}}|{{{e}}}}}}}{{#if:| {{{u}}}}} {{#if:|{{{lhs}}} = }}cos{{#if:φ|φ}}{{#if:|{{{3}}}}}{{#if:|{{{4}}}}}{{#if:|{{{5}}}}}{{#if:|{{{6}}}}}{{#if:|{{{7}}}}}{{#if:|{{{8}}}}}{{#if:|{{{9}}}}}{{#if:|{{{10}}}}}{{#if:|{{{11}}}}}{{#if:|{{{12}}}}}{{#if:|{{{13}}}}}{{#if:|{{{14}}}}}{{#if:|{{{15}}}}}{{#if:|{{{16}}}}}{{#if:|{{{17}}}}}{{#if:|{{{18}}}}}{{#if:|{{{19}}}}}{{#if:|{{{20}}}}}{{#if:|×10^{{#ifeq:{{#expr:{{{e}}}<0}}|1|−{{#expr:-{{{e}}}}}|{{{e}}}}}}}{{#if:| {{{u}}}}}
"She disputed his statement that 'Voltaire never said "I disapprove of what you say, but I will defend to the death your right to say {{gaps|it."|'|"}} {{{lhs}}} = }}it."{{#if:'|'}}{{#if:"|"}}{{#if:|{{{4}}}}}{{#if:|{{{5}}}}}{{#if:|{{{6}}}}}{{#if:|{{{7}}}}}{{#if:|{{{8}}}}}{{#if:|{{{9}}}}}{{#if:|{{{10}}}}}{{#if:|{{{11}}}}}{{#if:|{{{12}}}}}{{#if:|{{{13}}}}}{{#if:|{{{14}}}}}{{#if:|{{{15}}}}}{{#if:|{{{16}}}}}{{#if:|{{{17}}}}}{{#if:|{{{18}}}}}{{#if:|{{{19}}}}}{{#if:|{{{20}}}}}{{#if:|×10^{{#ifeq:{{#expr:{{{e}}}<0}}|1|−{{#expr:-{{{e}}}}}|{{{e}}}}}}}{{#if:| {{{u}}}}}
{{gaps|1.602|176|487(40)|e=-19|u=C}} {{{lhs}}} = }}1.602{{#if:176|176}}{{#if:487(40)|487(40)}}{{#if:|{{{4}}}}}{{#if:|{{{5}}}}}{{#if:|{{{6}}}}}{{#if:|{{{7}}}}}{{#if:|{{{8}}}}}{{#if:|{{{9}}}}}{{#if:|{{{10}}}}}{{#if:|{{{11}}}}}{{#if:|{{{12}}}}}{{#if:|{{{13}}}}}{{#if:|{{{14}}}}}{{#if:|{{{15}}}}}{{#if:|{{{16}}}}}{{#if:|{{{17}}}}}{{#if:|{{{18}}}}}{{#if:|{{{19}}}}}{{#if:|{{{20}}}}}{{#if:-19|×10^{{#ifeq:{{#expr:-19<0}}|1|−{{#expr:--19}}|-19}}}}{{#if:C| C}}
64 MB ({{gaps|64|base=2|e=20}} bytes) {{{lhs}}} = }}64{{#if:|{{{2}}}}}{{#if:|{{{3}}}}}{{#if:|{{{4}}}}}{{#if:|{{{5}}}}}{{#if:|{{{6}}}}}{{#if:|{{{7}}}}}{{#if:|{{{8}}}}}{{#if:|{{{9}}}}}{{#if:|{{{10}}}}}{{#if:|{{{11}}}}}{{#if:|{{{12}}}}}{{#if:|{{{13}}}}}{{#if:|{{{14}}}}}{{#if:|{{{15}}}}}{{#if:|{{{16}}}}}{{#if:|{{{17}}}}}{{#if:|{{{18}}}}}{{#if:|{{{19}}}}}{{#if:|{{{20}}}}}{{#if:20|×2^{{#ifeq:{{#expr:20<0}}|1|−{{#expr:-20}}|20}}}}{{#if:| {{{u}}}}} bytes)

Performance impact

Template:Gaps allows up to 20 parameters, and displays the gaps by setting the left-margin space of each group. The gaps are not actual spaces, so a copy/paste of the text is treated as connected, consecutive text. Template:Gaps is coded with minimal wikitext markup, so equivalent hand-coded markup could not be much shorter. Counting the length of the span-tags, there can be 15,800 instances of 2-part {gaps}, or 9,500 uses of 3-part gaps, or 6,800 with 4-part gaps (etc.), per page. The template uses a minimal expansion depth of only 2 levels (of the if-else nesting limit, such as 40 maximum), and if those 2 levels are exceeded, only the first portion will be shown. Although the text, as displayed, is consecutive as on-screen text, {gaps} for a number cannot be used in a calculation because the internal markup contains the invisible <span> tags which would be invalid text in typical numeric processing.

See also

  • {{gapnum}} - format a number to show 3-digit gaps, with decimal gaps of 3 or 4 digits
  • {{Val/delimitnum}} - format a number to show commas, but decimal gaps of 3 or 4 digits
  • {{convert/gaps}} - convert an amount to show 3-digit gaps, with decimal gaps
  • {{Space}} - to create alignment between adjacent text lines, or to space out titles, etc.