Permalink
Browse files

Markdown now handles unknown character entities

  • Loading branch information...
1 parent 7194da2 commit 0bba7d180bd546365ee7e8932f1090b27b0db7d8 @drbrain drbrain committed Nov 26, 2012
Showing with 14 additions and 1 deletion.
  1. +6 −1 lib/rdoc/markdown.kpeg
  2. +8 −0 test/test_rdoc_markdown.rb
View
7 lib/rdoc/markdown.kpeg
@@ -1082,7 +1082,12 @@ HexEntity = "&" "#" /[Xx]/ < /[0-9a-fA-F]+/ > ";"
DecEntity = "&" "#" < /[0-9]+/ > ";"
{ [text.to_i].pack 'U' }
CharEntity = "&" </[A-Za-z0-9]+/ > ";"
- { HTML_ENTITIES[text].pack 'U*' }
+ { if entity = HTML_ENTITIES[text] then
+ entity.pack 'U*'
+ else
+ "&#{text};"
+ end
+ }
NonindentSpace = " " | " " | " " | ""
Indent = "\t" | " "
View
8 test/test_rdoc_markdown.rb
@@ -132,6 +132,14 @@ def test_parse_block_quote_separate
assert_equal expected, doc
end
+ def test_parse_char_entity
+ doc = parse '&pi; &nn;'
+
+ expected = doc(para('π &nn;'))
+
+ assert_equal expected, doc
+ end
+
def test_parse_code
doc = parse "Code: `text`"

0 comments on commit 0bba7d1

Please sign in to comment.