Template:Ns

From Simple English Wikipedia, the free encyclopedia
Jump to navigation Jump to search

   

Template documentation[view] [edit] [history] [purge]

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

Usage and examples[change source]

The following show several examples on each line:

  • Using text:   Three{{ns}}spaces{{ns}}between{{ns}}each{{ns}}word
  produces:   Three   spaces   between   each   word
  • Using text:   Ten{{ns|10}}eight{{ns|8}}six{{ns|6}}four{{ns|4}}!
  produces:   Ten          eight        six      four    !

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

In translation of text to uppercase letters, the spacing is retained. Compare:

  • {{uc: Begin{{ns|4}}end }} → BEGIN    END
  • {{uc: Begin{{spaces|4}}end }} → BEGIN&NBSP;&NBSP;&NBSP;&NBSP;END

For gaps wider than 83 spaces, then multiple instances can be used, such as "{{ns|80}}{{ns|10}}" to insert 90 non-breaking spaces.

Performance considerations[change source]

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 text formatting. It uses the parser function "padleft:" to repeat "&#160;" several, or dozens, of times. Also, the parser-expansion depth has been kept limited, as only 5 levels deep, to allow use anywhere, to generate spaces in any complex templates or wikitables.

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 " &nbsp;" and hence, 3 spaces is the first gap needing longer markup. The short template name, "ns" avoids interleaving letters as "nsbp" for dyslexic users.

For text gaps wider than 83 spaces, then multiple instances of {ns} can be used, such as "{{ns|80}}{{ns|10}}" to insert 90 non-breaking spaces.

TemplateData[change source]

This is the TemplateData documentation for this template used by VisualEditor and other tools; see the monthly parameter usage report for this template.

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
https://simple.wikipedia.org/wiki/Template:Ns
simple.wikipedia.org
crawl=CC-MAIN-2021-04
43292
application/http; msgtype=response
sha1:OTLO3MYF6YRQHIBRXRATJVAL3URG5OBW
<urn:uuid:1788f74c-7107-4181-a74b-38e9a2fc76bd>
2021-01-18T04:33:02Z
208.80.154.224
text/html
sha1:7NB47FN3XMDZ6VKGHS2KKGRPCW3ZKLJD
<urn:uuid:05a9a11f-0c5e-477a-bb87-6514f89e0294>
https://simple.wikipedia.org/wiki/Template:Ns
response
<urn:uuid:1ab208f7-1968-42b2-a2b3-c71ee8c7004a>
isPartOf: CC-MAIN-2021-04
publisher: Common Crawl
description: Wide crawl of the web for January 2021
operator: Common Crawl Admin (info@commoncrawl.org)
hostname: ip-10-67-67-32.ec2.internal
software: Apache Nutch 1.17 (modified, https://github.com/commoncrawl/nutch/)
robots: checked via crawler-commons 1.2-SNAPSHOT (https://github.com/crawler-commons/crawler-commons)
format: WARC File Format 1.1
conformsTo: http://iipc.github.io/warc-specifications/specifications/warc-format/warc-1.1/