-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Improve markdown list rendering #2687
Improve markdown list rendering #2687
Conversation
Does that correctly indent multi-level lists? I tried fixing this before but the code needed significantly more changes to track indentation levels (I briefly looked at https://codeberg.org/flausch/mdcat/src/branch/main/src/render.rs) |
No, though the previous solution doesn't seem to work with it either. I'm writing some tests to investigate that further. This doesn't actually change how lists work. Rather I think the keyword arguments are not even recognized as lists, but the line endings themselves are converted into line breaks. This change simply inserts line breaks in the same way as line breaks are inserted at the end of for example paragraphs. |
@archseer now it handles nested lists, however it's very brittle since depending on the input source the parser can start inserting paragraphs into the list items. For example this input - item 1
- subitem 1
- item 2
- subitem 2
- item 1
- subitem 1 breaks the formatting since paragraphs are inserted into the list items causing extra newlines to be added in the output. The problem seems pretty complex with tagged events being able to nest almost arbitrarily. EDIT:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code now handles nested, numbered and multi-paragraph lists. Hard and soft line breaks and multiple paragraphs are indented on a best effort to match the overall indentation of the list.
Two spaces are currently chosen as the default indentation per level, but could be changed.
Known bugs:
- Fenced code blocks are not working properly inside of lists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! Thanks
* Cleanup old commented code * Implement line breaks in markdown rendering * Implement markdown nested, numbered and multiparagraph lists
Render line breaks parsed by the markdown parser.
Before:
After: