Edge Rewrite
// HTMLRewriter · presentation

This page was redesigned at the edge.

Cloudflare fetched the original article and streamed it through HTMLRewriter to apply an entirely new visual system without rebuilding the source page.

// request.cf · coarse context

A page that knows where it met you.

Only coarse request metadata is shown. This demo does not display or persist visitor IP addresses.

Country
US
Cloudflare location
CMH
Connection
HTTP/2
Language
Not provided

Ray ID: a23791b37b61d96e

Jump to content

Template:Ns/doc

From Wikipedia, the free encyclopedia

Template:ns is designed to insert between 0 and 83 non-breaking (non-linewrapping) spaces rapidly according to the number assigned as its first (unnamed) parameter. If this parameter is not supplied or its value is not numeric, it inserts a default three non-breaking spaces.

Do not insert huge numbers of non-breaking spaces to achieve a particular article layout. The width of non-breaking spaces varies between platforms and fonts, and on mobile devices (over half of readers) they are likely to make content overflow the available width. Differences between fonts make them unsuitable for precisely matching the width of any other text; consider {{0}} to match the width of specific text.

Usage and examples

[edit]

Default behaviour

[edit]
Three{{ns}}spaces{{ns}}between{{ns}}each{{ns}}word

Three   spaces   between   each   word

Custom number of spaces

[edit]

The effect of the count, such as in "{{ns|30}}" is identical to putting 30 copies of " " into the text.

Ten{{ns|10}}eight{{ns|8}}six{{ns|6}}four{{ns|4}}!

Ten          eight        six      four    !

Comparison with {{spaces}}

[edit]

In translation of text to uppercase letters with {{uc}}, the spacing is retained.

{{uc:Begin{{ns|4}}end}}

BEGIN    END

{{uc:Begin{{spaces|4}}end}}

BEGIN    END

Performance considerations

[edit]

Template:ns has been designed to rapidly insert a few, or numerous, non-breaking spaces where wrapping is not wanted, such as to pad table headings or align some entries in columns. It has been clocked to run faster than 1,530x times per second (in December 2012). The number of spaces, from 0 to 83, does not affect the speed of formatting. It invokes the parser function "padleft:" to repeat " " several, or dozens, of times. Also, the expansion depth has been kept limited, as only 5 levels deep, to allow use anywhere, to generate spaces in any complex templates or tables.

Beyond the maximum count of 83 spaces, the template truncates at 500-characters long (limited by padleft), with "&#" at the end. The default count, as 3 spaces, was chosen because a 1-or-2-space gap is often coded as simply "  " and hence, 3 spaces is the first gap needing longer markup. The short template name, "ns" avoids transposing letters as "nsbp" for dyslexic users.

TemplateData

[edit]
This is the TemplateData for this template used by TemplateWizard, VisualEditor and other tools. See a monthly parameter usage report for Template:Ns in articles based on its TemplateData.

TemplateData for Ns

Inserts a given number of non breaking spaces.

Template parameters

ParameterDescriptionTypeStatus
Number1

The number of spaces to insert. Must be less than 83. The default is three spaces.

Stringoptional

See also

[edit]