Skip to content

Commit

Permalink
Merge pull request readthedocs#122 from Anntoin/master
Browse files Browse the repository at this point in the history
Add visit_html_block
  • Loading branch information
ericholscher authored Oct 9, 2018
2 parents 9c15d32 + be55a6d commit 298caf6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
8 changes: 7 additions & 1 deletion recommonmark/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down
22 changes: 21 additions & 1 deletion tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ def test_horizontal_rule(self):
"""
)

def test_html(self):
def test_html_inline(self):
self.assertParses(
"""
Foo
Expand All @@ -423,6 +423,26 @@ def test_html(self):
"""
)

def test_html_block(self):
self.assertParses(
"""
Foo
<div>
<blink>Blink</blink>
</div>
""",
"""
<?xml version="1.0" ?>
<document source="&lt;string&gt;">
<paragraph>Foo</paragraph>
<raw format="html" xml:space="preserve">&lt;div&gt;
&lt;blink&gt;Blink&lt;/blink&gt;
&lt;/div&gt;</raw>
</document>
"""
)

def test_eval(self):
self.assertParses(
"""
Expand Down

0 comments on commit 298caf6

Please sign in to comment.