MarkdownRenderer should emit extra newline after list
Closed this issue · 4 comments
Using latest version 1.2.1. Here's a simple round-trip python script:
from mistletoe import Document
from mistletoe.markdown_renderer import MarkdownRenderer
d = None
with open('test.md', 'r') as f:
d = Document(f)
with open('test.md', 'w') as f:
with MarkdownRenderer() as r:
f.write(r.render(d))
If I run this script on this markdown file:
- Item1
- Item2
- Item3
Some text
it will output:
- Item1
- Item2
- Item3
Some text
if I run it again on this output, it will produce:
- Item1
- Item2
- Item3
Some text
So the text has become part of the final list item, changing the document layout. The same behavior is also exhibited with ordered lists.
There are actually quite a few places where newlines are deleted, changing the formatting (sticking paragraphs together and such).
I don't think so, I'm on Linux and running file -k test.md
outputs test.md: ASCII text
so the line endings are just \n
.
I'm sorry, looking at it again and I am actually able to reproduce. And it looks like you are experiencing #56 then. :)
I.e. change your code to the following and the MarkdownRenderer
will work correctly (because the renderer will manage to add its BlankLine
and other tokens to the parsing process):
from mistletoe import Document
from mistletoe.markdown_renderer import MarkdownRenderer
with MarkdownRenderer() as r:
with open('test.md', 'r') as f:
d = Document(f)
with open('test.md', 'w') as f:
f.write(r.render(d))
So I'm closing this as answered. Feel free to reopen by commenting on this issue.