What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 133 Stack Exchange communities.

I've just posted an answer that involved some HTML, which I indented by four spaces.

<a>http://some/url/with&nbsp;nbsp/</a>

compare to the original input I made:

<a>http://some/url/with&nbsp;nbsp/</a>

It seems as though &nbsp; gets replaced by an actual non-breaking space within a code section in the final output. I think this was not always the case (can someone confirm?), and it generally contradicts the meaning of a code section.

This is also inconsistent with the way text within backticks is treated. Now I know I could circumvent that by using &amp;nbsp;, but I'm very hesitant of this double encoding of source code.

Is it a bug?

share|improve this question
8  
Better use &amp;amp;nbsp; to be double-super safe... –  Hilarious Comedy Pesto Jul 7 '09 at 18:14
3  
@Pesto: This was not helpful. At all. –  Tomalak Jul 7 '09 at 18:18
5  
He wasn't trying to be –  jjnguy Jul 7 '09 at 20:34
2  
Refresh this page, and watch the first code block in the question: you can see the &nbsp; get changed to a space! –  Blorgbeard Jul 8 '09 at 5:14
    
@Blorgbeard: Definitely a client-side bug. Strange but I've missed this glitch so far. Chances are that this will never be fixed since it would instantly invalidate all those "work-arounded" code samples. –  Tomalak Jul 8 '09 at 7:10

4 Answers 4

up vote 1 down vote accepted

This appears fixed, at least to me, in the later prettify.js we've deployed.

share|improve this answer

If you check the source of the page, the &nbsp; is written as &amp;nbsp;, so the double-decoding is happening on the client, not the server. That's pretty interesting.

It's a bug in the code formatter itself. Isn't that a component written externally to SO?

share|improve this answer
2  
google prettify code.google.com/p/google-code-prettify –  Jeff Atwood Jul 7 '09 at 18:26
2  
@Jeff @wood: Time to submit an issue to Google. –  XMLbog Jul 7 '09 at 18:30
3  
@Jeff: Are you trying to suggest Google did something wrong?! –  Hilarious Comedy Pesto Jul 7 '09 at 18:31
1  
@Pesto: I told you he was a MS fanboi apologist! –  GEOCHET Jul 7 '09 at 18:31
1  
@Jef fAtwood: You should fork prettify and give Spolsky a heart attack. –  GEOCHET Jul 7 '09 at 18:38
1  
So if I had to guess then I'd say that this is one of the bugs that can never be fixed because there is an unknown number of code samples that are built around it. They would instantly become invalid. –  Tomalak Jul 8 '09 at 7:13
    
@Tomalak ​ It only means that people will have to edit them, when the find them. –  Brad Gilbert Aug 14 '09 at 15:19
    
@Brad Gilbert: You could look at it that way, yes. But it also means that code will be subtly wrong for J. Random Coder, who finds the page through Google. Which is sub-optimal. –  Tomalak Aug 25 '09 at 13:38

It is a bug, as shown by this example:

<td>&nbsp;</td>
<td>&amp;nbsp;</td>

The first is &nbsp; and the second is &amp;nbsp;. (I've used an extra level of entification to type the preceding sentence, and hope that it still comes out right when I post it.) Really nasty is that the preview initially shows the code as typed, but then replaces it with a space when it syntax-colours it after some random interval.

The bug does seem to be peculiar to nbsp. I haven't found any other character code that does it.

share|improve this answer

here is an example of the bug:

http://stackoverflow.com/questions/31870/using-a-html-entity-in-xslt-e-g-nbsp

share|improve this answer
    
Here's some more hairpulling: meta.stackexchange.com/questions/12620 –  random Aug 7 '09 at 10:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .