mirror of
https://github.com/vale981/recommonmark
synced 2025-03-05 10:01:39 -05:00
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
This commit is contained in:
parent
9c15d32547
commit
be55a6de90
2 changed files with 28 additions and 2 deletions
|
@ -218,13 +218,19 @@ class CommonMarkParser(parsers.Parser):
|
|||
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())
|
||||
|
||||
|
|
|
@ -403,7 +403,7 @@ class TestParsing(unittest.TestCase):
|
|||
"""
|
||||
)
|
||||
|
||||
def test_html(self):
|
||||
def test_html_inline(self):
|
||||
self.assertParses(
|
||||
"""
|
||||
Foo
|
||||
|
@ -423,6 +423,26 @@ class TestParsing(unittest.TestCase):
|
|||
"""
|
||||
)
|
||||
|
||||
def test_html_block(self):
|
||||
self.assertParses(
|
||||
"""
|
||||
Foo
|
||||
|
||||
<div>
|
||||
<blink>Blink</blink>
|
||||
</div>
|
||||
""",
|
||||
"""
|
||||
<?xml version="1.0" ?>
|
||||
<document source="<string>">
|
||||
<paragraph>Foo</paragraph>
|
||||
<raw format="html" xml:space="preserve"><div>
|
||||
<blink>Blink</blink>
|
||||
</div></raw>
|
||||
</document>
|
||||
"""
|
||||
)
|
||||
|
||||
def test_eval(self):
|
||||
self.assertParses(
|
||||
"""
|
||||
|
|
Loading…
Add table
Reference in a new issue