Skip to content

Commit

Permalink
Process linebreaks and convert them to br element.
Browse files Browse the repository at this point in the history
  • Loading branch information
RaptorCZ committed Jun 30, 2019
1 parent cbcfbff commit 357a732
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions recommonmark/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ def visit_text(self, mdnode):
def visit_softbreak(self, _):
self.current_node.append(nodes.Text('\n'))

def visit_linebreak(self, _):
self.current_node.append(nodes.raw('', '<br />', format='html'))

def visit_paragraph(self, mdnode):
p = nodes.paragraph(mdnode.literal)
p.line = mdnode.sourcepos[0][0]
Expand Down
18 changes: 18 additions & 0 deletions tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,24 @@ def test_eval(self):
"""
)

def test_linebreak(self):
self.assertParses(
"""
line1
line2
""",
"""
<?xml version="1.0" ?>
<document source="&lt;string&gt;">
<paragraph>
line1
<raw format="html" xml:space="preserve">&lt;br /&gt;</raw>
line2
</paragraph>
</document>
"""
)


if __name__ == '__main__':
unittest.main()

0 comments on commit 357a732

Please sign in to comment.