From be55a6de90242b0db052b556f1a052db87a643aa Mon Sep 17 00:00:00 2001 From: Anntoin Wilkinson Date: Fri, 5 Oct 2018 14:37:33 +0100 Subject: [PATCH] Add visit_html_block Without this any html_block nodes processed by the parser are dropped. `visit_html_block` uses the existing logic for `visit_html_inline`. Added a test case to check html_blocks are parsed as expected. Fixes: https://github.com/rtfd/recommonmark/issues/121 --- recommonmark/parser.py | 8 +++++++- tests/test_basic.py | 22 +++++++++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/recommonmark/parser.py b/recommonmark/parser.py index 299c477..857aded 100644 --- a/recommonmark/parser.py +++ b/recommonmark/parser.py @@ -218,13 +218,19 @@ def visit_block_quote(self, mdnode): self.current_node.append(q) self.current_node = q - def visit_html_inline(self, mdnode): + def visit_html(self, mdnode): raw_node = nodes.raw(mdnode.literal, mdnode.literal, format='html') if mdnode.sourcepos is not None: raw_node.line = mdnode.sourcepos[0][0] self.current_node.append(raw_node) + def visit_html_inline(self, mdnode): + self.visit_html(mdnode) + + def visit_html_block(self, mdnode): + self.visit_html(mdnode) + def visit_thematic_break(self, _): self.current_node.append(nodes.transition()) diff --git a/tests/test_basic.py b/tests/test_basic.py index 8fa0142..545c097 100644 --- a/tests/test_basic.py +++ b/tests/test_basic.py @@ -403,7 +403,7 @@ def test_horizontal_rule(self): """ ) - def test_html(self): + def test_html_inline(self): self.assertParses( """ Foo @@ -423,6 +423,26 @@ def test_html(self): """ ) + def test_html_block(self): + self.assertParses( + """ + Foo + +
+ Blink +
+ """, + """ + + + Foo + <div> + <blink>Blink</blink> + </div> + + """ + ) + def test_eval(self): self.assertParses( """