Template:Nw: Difference between revisions

From the Super Mario Wiki, the Mario encyclopedia
Jump to navigationJump to search
m (Porplemontage moved page Template:Nowrap to Template:Nw)
m (Text replacement - "({{|[Tt]em\|)[Nn]owrap" to "$1nw")
Line 6: Line 6:
== Usage ==
== Usage ==
<pre>
<pre>
Lots of text {{nowrap|10 kg (22 lb)}} more text.
Lots of text {{nw|10 kg (22 lb)}} more text.
</pre>
</pre>


Line 26: Line 26:


For text that includes an equal sign "=", precede the text with <code>1=</code>. For example:
For text that includes an equal sign "=", precede the text with <code>1=</code>. For example:
:<code><nowiki>{{nowrap|</nowiki>1=2 + 2 = 4}}</code>
:<code><nowiki>{{nw|</nowiki>1=2 + 2 = 4}}</code>


Which renders this:
Which renders this:
:{{nowrap|1=2 + 2 = 4}}
:{{nw|1=2 + 2 = 4}}


For text that includes a vertical bar "|", escape the bar(s) with <code><nowiki>&amp;#124;</nowiki></code> or <code><nowiki>{{!}}</nowiki></code>. For instance like this:
For text that includes a vertical bar "|", escape the bar(s) with <code><nowiki>&amp;#124;</nowiki></code> or <code><nowiki>{{!}}</nowiki></code>. For instance like this:
:<code><nowiki>{{nowrap|</nowiki>&amp;#124;2&amp;#124; < 3}}</code>
:<code><nowiki>{{nw|</nowiki>&amp;#124;2&amp;#124; < 3}}</code>


Or like this:
Or like this:
:<code><nowiki>{{nowrap|{{!}}2{{!}} < 3}}</nowiki></code>
:<code><nowiki>{{nw|{{!}}2{{!}} < 3}}</nowiki></code>


Which renders this:  
Which renders this:  
:{{nowrap|&#124;2&#124; < 3}}
:{{nw|&#124;2&#124; < 3}}


== Technical details ==
== Technical details ==

Revision as of 10:27, June 4, 2024

This template prevents word wraps (line breaks) in text and links that contain spaces.

Before you use this template you might want to read up on line-break handling.

Usage

Lots of text {{nw|10 kg (22 lb)}} more text.

It may render like this:

Lots of text 10 kg (22 lb)
more text.

Or like this:

Lots of text
10 kg (22 lb) more text.

But it will not render like this:

Lots of text 10 kg (22
lb) more text.

Handling interpreted characters

Templates have problems to handle parameter data that contains equal signs "=" or vertical bars "|". But there are also workarounds:

For text that includes an equal sign "=", precede the text with 1=. For example:

{{nw|1=2 + 2 = 4}}

Which renders this:

2 + 2 = 4

For text that includes a vertical bar "|", escape the bar(s) with &#124; or {{!}}. For instance like this:

{{nw|&#124;2&#124; < 3}}

Or like this:

{{nw|{{!}}2{{!}} < 3}}

Which renders this:

|2| < 3

Technical details

The actual code that does the job is this HTML+CSS code:

<span style="white-space:nowrap">This text will not wrap</span>

Spaces at the beginning or end of your text will fall outside the no-wrap tag in the rendered text due to MediaWiki rendering mechanisms.