CommonMark-py icon indicating copy to clipboard operation
CommonMark-py copied to clipboard

Non-breaking space ( ) should be preserved on rendering

Open millerdev opened this issue 10 years ago • 3 comments

Python 3.3.2 (v3.3.2:d047928ae3f6, May 13 2013, 13:52:24)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import CommonMark as commonmark
>>> parser = commonmark.DocParser()
>>> renderer = commonmark.HTMLRenderer()
>>> renderer.render(parser.parse("big   space"))
'<p>big   space</p>\n'
>>> expected = '<p>big \u00A0 space</p>\n'

The CommonMark spec shows an example of &nbsp; being replaced by something other than a normal space (presumably a Unicode non-breaking space character).

millerdev avatar Nov 29 '14 20:11 millerdev

From a doc that the spec links to:

  "&nbsp;": { "codepoints": [160], "characters": "\u00A0" },
  "&nbsp": { "codepoints": [160], "characters": "\u00A0" },

waynew avatar Dec 13 '14 12:12 waynew

My example showed that the renderer translates it to a normal space, not \u00A0. I think this is a bug in CommonMark

millerdev avatar Feb 13 '15 20:02 millerdev

I can confirm this bug. The spaces are all ord(u' ') == 32 while ord(u"\u00A0") == 160.

tvannahl avatar Apr 12 '15 17:04 tvannahl