2

Below code is indented with 2  .

  <- no-break space
  <- no-break space

I wrote this code block manually, i.e. prepend 4 spaces to each line.

Why don't I use Ctrl+K? Because it didn't work.

  • If lines are indented with 3 or less normal spaces, Ctrl+K prepends 4 spaces.
  • If lines are indented with 4 or more normal spaces, Ctrl+K removes 4 spaces.

But if lines are indented with any number of &nbsp;, Ctrl+K does nothing.


I don't think 4 &nbsp; should be recognized as code block indentation. But if so, Ctrl+K should prepend 4 spaces to wrap with code block.

I've found this problem on editing other's post. OP seems to copied &nbsp; indented code from https://www.npmjs.com/package/gulp-babel.

Chrome 57 and Edge 38 on Windows 10 / rev 2017.1.6.24571

  • Why are you indenting code with non-breaking spaces? – Cai Jan 6 '17 at 13:27
  • @Cai I found this problem when I edited someone's post, and I don't do that... – unarist Jan 6 '17 at 13:30
  • Fair enough. I can't think of any reason to legitimately use non-breaking spaces to indent code... if you see anyone doing it again, tell them to stop it! :) – Cai Jan 6 '17 at 13:31
  • It might happen when you copy code from a site, but really, allowing this brings more problems than it solves. – Patrick Hofman Jan 6 '17 at 13:33
2

Because Markdown simply doesn't recognize a non-breaking space as a valid code block indentation character. Just 4 spaces or a single tab is defined as identification character.

The question which remains is: should non-breaking spaces be supported? Personally I don't think so. The use case is rare, this is how Markdown is documented to work and it has proven to work this way for years. Taking non-breaking spaces or similar looking characters as identifier don't really fix a problem.

You must log in to answer this question.

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