Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed ordered list markdown renderer. #112

Merged
merged 3 commits into from
May 29, 2022

Conversation

BobMarlon
Copy link
Contributor

Hi,
first of all, thanks for creating this library! That was just what I needed right now. I stumbled over a bug however, which caused ordered lists to not be enumerated correctly if rendered using the MarkdownRenderer.

This can be reproduced like that:

import marko
from marko.md_renderer import MarkdownRenderer

md = marko.Markdown(renderer=MarkdownRenderer)
doc = md.parse("""
1. a
2. b
3. c
""")
print(md.render(doc))

Prints:

1. a
1. b
1. c

The fix is kinda hacky though. I also didn't add tests...

@frostming
Copy link
Owner

fwiw the current output is also a valid markdown and can be rendered rightly on most markdown renderer, not a bug.

what doesn't work well?

marko/md_renderer.py Outdated Show resolved Hide resolved
@BobMarlon
Copy link
Contributor Author

Well, I guess it depends on how you look at it. The output may be valid but If you take a look at the documentation in the MarkdownRenderer class:

It is useful for, e.g. merging sections and formatting documents.

I would have expected that if I simply parse a markdown document without doing anything and then render it again into markdown, that I get the same as in the beginning. This is why I noticed that because formatting documents was my use case.

@codecov
Copy link

codecov bot commented May 28, 2022

Codecov Report

Merging #112 (3249929) into master (a8997f0) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #112      +/-   ##
==========================================
- Coverage   95.56%   95.56%   -0.01%     
==========================================
  Files          19       19              
  Lines        1781     1780       -1     
  Branches      289      289              
==========================================
- Hits         1702     1701       -1     
  Misses         42       42              
  Partials       37       37              
Flag Coverage Δ
unittests 95.56% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
marko/md_renderer.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a8997f0...3249929. Read the comment docs.

@BobMarlon BobMarlon closed this May 28, 2022
@BobMarlon BobMarlon reopened this May 28, 2022
@frostming frostming merged commit e6d36dc into frostming:master May 29, 2022
@BobMarlon BobMarlon deleted the fix-ordered-list-md-renderer branch May 29, 2022 04:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants