Template talk:Nowrap

From Wikipedia, the free encyclopedia
Jump to: navigation, search

Replaces <nobr>[edit]

This template is a replacement for the unsupported nonstandard <nobr> tag. cesarb 19:50, 20 Mar 2005 (UTC)

Stronger than non-breaking spaces[edit]

It is also even stronger than using non-breaking spaces ("&nbsp;"s) between words, viz. it will ignore (right-hand) margins, borders, etc. David Kernow (talk) 06:45, 26 November 2006 (UTC)

Lorem ipsum, quia dolor sit, amet, consectetur, adipisci uelit, sed quia non numquam eius modi tempora incidunt, ut labore et dolore magnam aliquam quærat uoluptatem. Vt enim ad minima ueniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem uel eum iure reprehenderit, qui in ea uoluptate uelit esse, quam nihil molestiæ consequatur, uel illum, qui dolorem eum fugiat, quo uoluptas nulla pariatur? At uero eos et accusamus et iusto odio dignissimos ducimus, qui blanditiis præsentium uoluptatum deleniti atque corrupti, quos dolores et quas molestias excepturi sint, obcæcati cupiditate non prouident, similique sunt in culpa, qui officia deserunt mollitia animi, id est laborum.
Lorem ipsum, quia dolor sit, amet, consectetur, adipisci uelit, sed quia non numquam eius modi tempora incidunt, ut labore et dolore magnam aliquam quærat uoluptatem. Vt enim ad minima ueniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem uel eum iure reprehenderit, qui in ea uoluptate uelit esse, quam nihil molestiæ consequatur, uel illum, qui dolorem eum fugiat, quo uoluptas nulla pariatur? At uero eos et accusamus et iusto odio dignissimos ducimus, qui blanditiis præsentium uoluptatum deleniti atque corrupti, quos dolores et quas molestias excepturi sint, obcæcati cupiditate non prouident, similique sunt in culpa, qui officia deserunt mollitia animi, id est laborum.
I don't see much of a difference. And it should: a non-breaking space is a space that will not allow breaking. How much stronger than "not" can you get? Could you be a bit more specific? Shinobu 15:33, 25 July 2007 (UTC)

Template nowraplinks[edit]

Hi everyone. I got tired of handling word wrapping in long link lists, for instance in navigation boxes. So I have made a new template similar to {{nowrap}}, but that only prevents word wraps in links. That is, it allows wraps between links and in normal text. Thus one single {{nowraplinks}} tag can surround the whole link list instead of having one {{nowrap}} tag around each link or using lots of &nbsp;.

I would like if some expert template editors (preferably with some CSS experience) take a loot at it to see that I didn't miss anything. I think this template might be used a lot once we deploy it.

Oh, I probably should mention that this template will need the addition of one line of CSS code to common.css. So I think this needs to be thoroughly checked and discussed before we deploy it. (And I am not an admin so I can not add that line of code myself.)

--David Göthberg 04:59, 10 August 2007 (UTC)

The necessary code was added to common.css some days ago so {{nowraplinks}} is now fully functional. --David Göthberg 14:18, 23 August 2007 (UTC)

Change of page code / looks[edit]

{{editprotected}}

I suggest the code between the noinclude tags be changed. (Mostly to make the page look better really.) The changes I suggest is using the new small padlock, the new {{template doc}} and the category comment, as recommended in Wikipedia:Template documentation. Here is how the full page code looks with my suggested changes:

<includeonly><span style="white-space:nowrap">{{{1}}}</span></includeonly><noinclude>
{{pp-template|small=yes}}
{{template doc}}
<!-- Add categories and interwikis to the /doc subpage, not here! -->
</noinclude>

--David Göthberg 14:31, 23 August 2007 (UTC)

Done. --- RockMFR 20:30, 23 August 2007 (UTC)

Even shorter coding[edit]

{{editprotected}} 17-Dec-2007: The coding currently uses "<includeonly>" which I don't think is needed in a highly size-critical template: the includeonly-tag adds 27 characters, and when the includeonly-tag is omitted, the result just shows "{{{1}}}" above the documentation, which is harmless and emphasizes that parameter-1 is required. Also, I recommend using a shorter comment, to reduce Template:Nowrap by 21%, from 185 bytes to 146 bytes:

<span style="white-space:nowrap">{{{1}}}</span><noinclude>
{{documentation}}<!--put categories & interwikis in /doc subpage, only!-->
</noinclude>

I am concerned about the template size, in conjunction with other templates used on a page, because I've hit template-buffer limits when repeated sub-templates contained only 500 characters. However, I really recommend using "&nbsp;" instead of a template, because "&nbsp;" (used once per wikilink) adds only 6 characters, not 185, and not even 146 characters to each non-wrapped wikilink. Remember, the MediaWiki language version 1.6 treats pages as template-expansion buffers, repeating all template contents as inline text. -Wikid77 (talk) 11:14, 17 December 2007 (UTC)

Yes check.svg Done.—Random832 17:23, 17 December 2007 (UTC)
  • Thank you. Excellent improvement: template shortened by 43% to 129 characters. Now it can be used in very large tables, such as a table of painters and their most famous paintings, or a table of all the notable towns in Germany. -Wikid77 (talk) 04:45, 2 January 2008 (UTC)

Template behaviour: two problems[edit]

{{editprotected}}

X mark.svg Not done, impossible. change made to documentation (but you could have done that yourself) —Random832 17:04, 23 January 2008 (UTC)

Problem 1[edit]

From the description of the template's action we have a certain expectation.

x{{nowrap| TEXT }}y

should yield

x<span style="white-space:nowrap"> TEXT </span>y

But in fact it yields

x <span style="white-space:nowrap">TEXT</span> y

I therefore request that the documentation be changed; or, preferably, that the coding of the template be fixed so that it behaves as specified. As things stand, breaks occur in unpredicted ways.

Alternatively, see the better but more radical alteration suggested below.

Use {{nowrap|x TEXT y}}, this is impossible without fundamental changes to how the parser works. —Random832 17:04, 23 January 2008 (UTC)
Thanks for fixing the documentation, Random. I didn't want to do it myself without raising the matter here first.
Could you point me to a fuller documentation of that rather serious problem in the parser? And please: could you look at the problem below and comment on it also? In particular, do you confirm that the same inadequacy in the parser rules out spaces being rendered as &nbsp;, at the start or the end of the enclosed string?
– Noetica♬♩Talk 21:35, 23 January 2008 (UTC)

Problem 2[edit]

Even if the behaviour of the template is altered as suggested above, there is a difficulty with the way browsers treat this code:

x<span style="white-space:nowrap"> TEXT </span>y

In recent versions of Firefox and IE at least, this code allows breaks to occur between x and TEXT, and between TEXT and y. Since this behaviour is itself unruly, I request that the coding of the template be altered so that a &nbsp; is substituted for each ordinary space in the enclosed text. This would ensure the desired result. It has the added advantage that multiple ordinary spaces would yield multiple instances of &nbsp;. Whether or not these are deprecated, they are sometimes convenient and sometimes intended.

These concerns arose out of investigations regarding markup for the hard space. See our draft proposal, which I have just amended in light of the anomalies raised above:

There is active discussion of the proposal at WT:MOS. Template editors will be very welcome there.

– Noetica♬♩Talk 23:53, 22 January 2008 (UTC)

Remark 1[edit]

The behaviour signaled above is part of a larger pattern. Also a'' x ''b leads to HTML a <i>x</i> b, with the spaces pulled out of the italic tags. −Woodstone (talk) 10:50, 23 January 2008 (UTC)

That's interesting. I wonder why things have been done in such a way? I suppose this behaviour with italics is safer than the behaviour that affects line breaks; but I can imagine situations in which this one might make a difference too.
– Noetica♬♩Talk 11:42, 23 January 2008 (UTC)

Remark 2[edit]

Even coding

x<span style="white-space:nowrap">&nbsp;TEXT&nbsp;</span>y

still results in a possible break before TEXT in IE (though not after it). Mysterious! −Woodstone (talk) 23:08, 23 January 2008 (UTC)

Confirmed! (And it makes no difference if &#160; is substituted for &nbsp;.) Firefox handles the code correctly. But you'll love this:

x&nbsp;<span style="white-space:nowrap">TEXT</span>&nbsp;y z

This also breaks before TEXT! In IE, not in Firefox. Note: I add " z" to permit a standard break, in testing. What else remains to be discovered? Woodstone, please let me write a report at WT:MOS, OK? I'll also amend WP:MOS, since these anomalies really should be noted. They certainly advance the case for ,,. They also tend to cast doubt on any template solutions for hard spaces.
– Noetica♬♩Talk 00:56, 24 January 2008 (UTC)–AMENDED CONTRIBUTION: A stray unmatched CODE tag is now deleted from an example.– Noetica♬♩Talk 06:07, 25 January 2008 (UTC)

{{nowrap}}, {{nowraplinks}} and {{nowrap begin}}[edit]

As a webmaster and Wikipedia editor I have worked a lot with line breaking issues. In the end I created {{nowraplinks}} and {{nowrap begin}} and their helper templates to solve/handle the problems with {{nowrap}}. I took a look at the suggestion above to use the wikimarkup 34,,kg to mean 34&nbsp;kg and it seems to me it is a good suggestion.

Of course what really is needed is that the World Wide Web Consortium (W3C) finally accept and standardise the old well working and easy to use HTML markup <nobr> + + </nobr>.

--David Göthberg (talk) 09:40, 26 February 2008 (UTC)

In defence of nowrap[edit]

Much said about the defiencies of the template and how &nbsp; does the job better but if its a non-breaking hyphen, en dash, degree sign, etc. you want, this is your template. Jɪmp 22:09, 25 January 2008 (UTC)

Actually not quite (in IE). Try {{nobreak|aaaaaa—}}bbbbbbb. The intention is to keep the em-dash attached to the left part and allow a break after it. Strangely enough IE does not allow the break after the em-dash. Actually a straight aaaaaa—bbbbbbb has the desired effect in IE. I did not delve deeper, but behaviour seems to be very erratic. −Woodstone (talk) 23:29, 25 January 2008 (UTC)
Yes, confirmed.
We note that {{nobreak}} is an alias for {{nowrap}}. Where are these aliases documented?
These codes behave in IE the same as the code Woodstone describes:
{{nowrap|aaaaaa–}}bbbbbbb [en dash]
{{nowrap|aaaaaa…}}bbbbbbb [preformed ellipsis]
For none of these markups does Firefox allow any breaks.
What other anomalies remain to be uncovered?
– Noetica♬♩Talk 05:26, 26 January 2008 (UTC)
For this particular case, a solution that works as intended in both IE and Firefox uses the HTML code for zero-width space:
aaaaaa–&#x200B;bbbbbbb
In the extensions section this is currently proposed by markup ,^,, leading to
aaaaaa–,^,bbbbbbb
Woodstone (talk) 12:31, 26 January 2008 (UTC)
Hmmm, some potentially unpredictable stuff and possibly more to be uncovered but the point I hoped to make is that this template (or equivalent) can do what you've noted. That is, aaa-bbb, 20–30&nbsp;°C allow breaks which may be undesireable. Jɪmp 07:04, 27 January 2008 (UTC)
I have just tried a whole bunch of methods to allow line wraps without causing any visible space and all of them failed in some way in at-least one of my web browsers...
The zero-width space caused visible blobs both in my old IE 5.5 and my recent version of Opera. But it worked fine in Firefox. So I don't think the zero-width markup ,^, should be deployed since it will only work in some browsers. But at-least it did wrap properly in all my browsers. (I have not tested with Safari since Safari is not available for my OS.)
But Jɪmp is right, {{nowrap}} does what it is supposed to do, it prevents line wraps in the text that it surrounds.
--David Göthberg (talk) 03:25, 14 March 2008 (UTC)

Nowrap how-to guide[edit]

I first rough version of Wikipedia:Line break handling is done. Its a how-to guide about how to handle word wraps (line breaks) at Wikipedia. Take a look and discuss it on its talk page.

--David Göthberg (talk) 21:40, 11 March 2008 (UTC)

Template broken?[edit]

Hi, this template doesn't seem to be working here: Nitrogen dioxide#Monomer-dimer equilibrium. It simply shows up as {{{1}}}. Not sure why the template parameter isn't being substituted; can anybody help?—Tetracube (talk) 19:10, 19 October 2009 (UTC)

It's the equal sign, which is not allowed in a parameter. Can be solved by using "1=" before the parameter. This is stated in the templates documentation. −Woodstone (talk) 20:27, 19 October 2009 (UTC)

Space in Documentation after j[edit]

Hello, ist there a reason to have a space after the j in the dokumentation?

We saw {{j |1 [[black rhino]]}} but {{j|800 [[zebra]]s}}. <br>May render like this: :We saw {{j |1 [[black rhino]]}} but<br>800 [[zebra]]s. <br>Or like this: :We saw {{j |1 [[black rhino]]}}<br>but 800 [[zebra]]s. <br>But ''not'' render like this: :We saw 1 [[black rhino|black<br>rhino]] but 800 [[zebra]]s.

--Diwas (talk) 21:07, 25 September 2011 (UTC)

Template:Nowrap5[edit]

Hello, to fix texts like “6 ft 6in (1.98m) and 17st 9 lbs (112 kg)” to a correct text and simple source text, I extended this template to up to five texts, see Template:Nowrap5. What you are thinking about it. The first use --Diwas (talk) 00:14, 25 November 2011 (UTC)

It has flaws. The most important one is that unused parameters will show as "{{{4}}} {{{5}}}". Not really convinced that it adds any functionality. The example in George Kruis is better served with {{convert}}. Edokter (talk) — 01:13, 25 November 2011 (UTC)
Thanx. The unused parameters, I saw it a while later. The {{convert}} is very good, especially for the autor of an article. I'm using it sometimes yet, but I'm not sure about it. May someone stated as 5 feet 4 inches and as 164 cm but {{convert}} will show 5 feet 4 inches (163 cm)? {{nowrap}} don't changes anything of the content, {{convert}} may change it by nuances.
And {{convert|6|ft|6|in|m|abbr=on}} and {{convert|17|st|9|lb|kg|abbr=on}} is not a very short and easy source text. --Diwas (talk) 04:17, 25 November 2011 (UTC)

Removed links[edit]

I see that the following were removed from Template:Nowrap/doc#See also with the edit note "removed links to obsolete methods":

  • {{nowraplinks}} – Prevents wraps inside links and only allows wraps between the links and in normal text. Very useful for link lists and easy to use.
  • {{nowrap begin}} – Prevents wraps in both text and links. For the trickier wrapping cases when you need full control, for instance in very complex link lists.

Are these really obsolete? The latter is recommended in Wikipedia:Line break handling. Both seem likely to be useful. — Quondumtc 06:03, 7 January 2012 (UTC)

brackets and escaping[edit]

Brackets within the Nowrap template, it has been suggested, might be a problem which can be solved by escaping or representing with the HTML character entities & # 91; (minus spaces) for the opening bracket and & # 93; (minus spaces) for the closing bracket. Is that so and, if it is so, should we add it to the template documentation? Nick Levinson (talk) 16:19, 7 August 2012 (UTC) (Corrected my link error: 16:24, 7 August 2012 (UTC))

Edit request on 01 February 2015[edit]

A protected redirect, Template:J, needs an incorrect redirect category (rcat) template removed and the correct rcat added. Please modify it as follows:

  • from this...
#REDIRECT  [[Template:Nowrap]] {{R from template shortcut}}
  • to this...
#REDIRECT  [[Template:Nowrap]]

{{Redr|from template shortcut}}
  • WHEN YOU COPY & PASTE, PLEASE LEAVE THE MIDDLE LINE BLANK FOR READABILITY.

Template Redr is an alias for the {{This is a redirect}} template, which is used to sort redirects into one or more categories. No protection rcat is needed, and if {{pp-protected}} and/or {{pp-move}} suffice, the This is a redirect template will detect protection level(s) and include them automatically. Thank you in advance! – Paine EllsworthCLIMAX! 19:35, 1 February 2015 (UTC)

I replaced it with {{R from template shortcut}}. I'm not sure what the benefits are using {{redr}}, apart from being able to add multiple categories. -- [[User:Edokter]] {{talk}} 20:32, 1 February 2015 (UTC)
Hi Edokter – one big added benefit is that Redr automatically senses protected redirects like this one. So the usual protection rcats are not needed, and they don't have to be manually removed if and when protection is lifted. Please use the Redr template to tag this redirect and any future redirects you protect. – Paine EllsworthCLIMAX! 20:43, 1 February 2015 (UTC)
Yes check.svg Done --Redrose64 (talk) 23:19, 1 February 2015 (UTC)
Thank you, Redrose64! – Paine 

Wraponce?[edit]

Is there a version of this template that will permit wraps but limit it to a certain number? Like if you want to limit a string of text to being wrapped into only two lines, when window resizing might otherwise force it into three or more lines, and it isn't feasible to manually insert a line break or to use <wbr>. postdlf (talk) 16:55, 4 April 2015 (UTC)