-
-
Notifications
You must be signed in to change notification settings - Fork 444
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
How to preserve empty lines? #705
Comments
Probably duplicate of #698.
The CommonMark specs are treating empty lines in a specific way (e.g they are used to stop processing list..etc.) and they have many associated rules with them. Changing this behavior (even with an opt-in switch) is not something I would like to maintain, and I'm not even sure it is practical, feasible without conflicting with existing rules. As you realized yourself, empty lines have a context dependent behavior. So my main advice would be to not pursue this road 🙂 |
I understand that this is not compliant with CommonMark and would make no sense in implementing it in Markdig. I am writing a note editor with these specifications:
I decided to use Markdig, because it covers 1. and 3. but the most important features are detecting links in simple text and preserving empty lines. Can you give me a few starting points how could I write a custom Markdig extension that would preserve empty lines? |
This is what ChatGPT wrote, but it doesn't work:
|
This more likely not trivial and unlikely possible by extending Markdig. You would have to fork it and modify its internals. |
Thank you for your explanations. |
Would it be possible to preserve empty lines?
Using
UseSoftlineBreakAsHardlineBreak()
preserves new lines, but not empty lines.I tried using
text.Replace("\n", "<br>")
but then titles and lists don't work.I tried using
text.Replace("\n", "<br>\n")
then titles and lists work, but there are too many empty lines.I tried using
text.Replace("\n\n", "<br><br>")
but then all markdown after a list is wrong.I tried using
text.Replace("\n\n", "<br>\n")
then titles and lists work, but not all empty lines are preserved.I tried using
text.Replace("\n\n", "<br><br>\n")
then titles and lists work, but everything else is wrong.Would it be possible to specify my own rule for this?
The text was updated successfully, but these errors were encountered: