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

It's possible that this is a duplicate of this question - but if so, I don't know why, and I can't verify whether it's the case. I've got a concrete example, although only dev (and maybe mods) will be able to get at the edit history I suspect, as it was within the first five minutes.

I answered this question including some code - but it didn't come out as code. As far as I could see, there were four spaces at the start of each line - but only some of it came out as code. I eventually fixed it up by replacing those first four visible spaces (with four spaces!) on each line... but it's not at all clear to me what was going on. Note that it caused the code not to be recognized as code in both the preview and the finished post (consistently, fortunately).

I've had this quite a few times, but only in the last 3-6 months. It's really annoying and puzzling - it makes the answerer look like they don't know how to use Markdown, when I think I can safely say I'm aware of how to format code by now...

If someone could check into the edit history, work out what spurious characters were present (assuming they really were) and give suggestions as to how they got there and how they can be avoided (by the system, not the user) that would be very helpful.

share|improve this question
2  
May be related to this. According to the OP's comments there, he wasn't doing anything special either but Chrome inserted some NBSPs on his behalf. Could be a (hopefully temporary) browser defect. –  Anna Lear Mar 14 '12 at 20:26
    
I have experienced the same and am using Chrome, as @AnnaLear commented. –  Oded Mar 14 '12 at 20:27
4  
Well I'm definitely using Chrome... if this is something which is coming up for multiple users, I think it would be reasonable to try to compensate for it... I just wish I knew how to reproduce it... –  Jon Skeet Mar 14 '12 at 20:29
    
@Jon As Anna notes, I have seen the same thing. I've seen it probably once a week in recent times. Until today I did not know what the issue was. Like you I have not been able to reproduce whatever it is with Chrome/SE that leads to the U+00A0 characters appearing. I would have imagined that the markdown parsing could treat U+00A0 the same as U+0020. –  David Heffernan Mar 14 '12 at 21:22
2  
Jon Skeet has spoken! It must be true! To the drawing board! draws Jon Skeet ... Wait, that's not right. –  animuson Mar 14 '12 at 21:33
    
For what it's worth, I do a fair amount of question and answer re-formatting for people in Firefox; the code-formatting button in the JavaScript editor always works for me, and for cases that require more drastic action, I shell out to vim. It feels likely to be browser-dependent. Are you pasting in code from elsewhere? Writing the entire thing by hand in the window? Placing the spaces by hand yourself or using the editor widget's {} button? –  sarnold Mar 14 '12 at 22:32
    
@sarnold: Writing code by hand in the window, manually spacing things - at least this time. I seem to remember that the Ctrl-K shortcut for the {} button hasn't helped when I've had similar problems in the past, but I'll give it a go... –  Jon Skeet Mar 14 '12 at 22:41

1 Answer 1

I don't know what's happening, I've not been able to reproduce it yet. However, there is one thing that would cause non-breaking spaces (U+00A0) to be inserted instead of regular spaces (U+0020): Setting the editor input <textarea>'s CSS property white-space to something that collapes spaces, i.e. anything except pre or pre-wrap.

In that case, the browser will turn some spaces into NBSPs, since they wouldn't be visible otherwise. If that whole idea sounds a bit crazy to you, you're not alone.

I have no idea why this style would be changed (except for interfering user styles/extensions/etc.), so I need help here.

If someone notices that the browser is converting your spaces into non-breaking ones, please see if the text area has a changed white-space setting, and maybe even if you can find out why.

If the paragraphs above sound like a foreign language to you, you'll probably not be able to help me, but there are enough web devs here that I'm hopeful someone can.

share|improve this answer
    
What could you do even if you found out that it was something like this? Could you, from your end, stop the NBSPs appearing? And why would you do that? Surely if the browser is putting in NBSPs in the scenario you describe, then it does so for good reason. –  David Heffernan Mar 17 '12 at 0:52
    
It seems like a few people, at least, have seen this behavior. Is there a downside to just supporting both A0 and 20? –  ThinkingStiff Jul 10 '12 at 4:39
    
@ThinkingStiff, it would be a deviation from Markdown, making things harder for other usage of the data. –  Arjan Jul 28 '12 at 10:29
    
And for those who don't speak foreign languages: pasting the following in the location bar of your browser might show the value: javascript:alert($(".wmd-input").css("white-space")); (Beware that some browsers remove the javascript: when pasting.) –  Arjan Jul 28 '12 at 10:32
    
(For those on Firefox: my above javascript:alert thingy no longer works in Firefox, as that browser has stopped accepting that in the location bar.) –  Arjan Mar 2 '13 at 8:12

You must log in to answer this question.

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