Skip to content

Commit

Permalink
fix: penultimate lines of multiline fragments being ignored by the Ma…
Browse files Browse the repository at this point in the history
…rkdown renderer (#201)
  • Loading branch information
Lordfirespeed authored Nov 26, 2023
1 parent 70e8e8d commit 5f4c550
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mistletoe/markdown_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ def fragments_to_lines(
if "\n" in fragment.text:
lines = fragment.text.split("\n")
yield current_line + lines[0]
for inner_line in lines[1:-2]:
for inner_line in lines[1:-1]:
yield inner_line
current_line = lines[-1]
else:
Expand Down
11 changes: 11 additions & 0 deletions test/test_markdown_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,17 @@ def test_images_and_links(self):
output = self.roundtrip(input)
self.assertEqual(output, "".join(input))

def test_multiline_fragment(self):
input = [
"[a link](<url-in-angle-brackets> '*emphasized\n",
"title\n",
"spanning\n",
"many\n",
"lines*')\n",
]
output = self.roundtrip(input)
self.assertEqual(output, "".join(input))

def test_thematic_break(self):
input = [
" ** * ** * ** * **\n",
Expand Down

0 comments on commit 5f4c550

Please sign in to comment.