mirror of
https://github.com/vale981/recommonmark
synced 2025-03-05 10:01:39 -05:00
Process linebreaks and convert them to br element.
This commit is contained in:
parent
cbcfbff243
commit
357a732caf
2 changed files with 21 additions and 0 deletions
|
@ -109,6 +109,9 @@ class CommonMarkParser(parsers.Parser):
|
|||
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]
|
||||
|
|
|
@ -459,6 +459,24 @@ class TestParsing(unittest.TestCase):
|
|||
"""
|
||||
)
|
||||
|
||||
def test_linebreak(self):
|
||||
self.assertParses(
|
||||
"""
|
||||
line1
|
||||
line2
|
||||
""",
|
||||
"""
|
||||
<?xml version="1.0" ?>
|
||||
<document source="<string>">
|
||||
<paragraph>
|
||||
line1
|
||||
<raw format="html" xml:space="preserve"><br /></raw>
|
||||
line2
|
||||
</paragraph>
|
||||
</document>
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
Loading…
Add table
Reference in a new issue