rolandshoemaker / CommonMark-py

Depreciated in favor of rtfd/CommonMark-py
Other
125 stars 12 forks source link

Non-breaking space ( ) should be preserved on rendering #13

Open millerdev opened 9 years ago

millerdev commented 9 years ago
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).

waynew commented 9 years ago

From a doc that the spec links to:

  "&nbsp;": { "codepoints": [160], "characters": "\u00A0" },
  "&nbsp": { "codepoints": [160], "characters": "\u00A0" },
millerdev commented 9 years ago

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

tvannahl commented 9 years ago

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