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

[REQUEST] add breaks option to Markdown #3395

Open
mroch opened this issue Jun 24, 2024 · 1 comment
Open

[REQUEST] add breaks option to Markdown #3395

mroch opened this issue Jun 24, 2024 · 1 comment

Comments

@mroch
Copy link

mroch commented Jun 24, 2024

in Markdown, a newline in a paragraph is a "soft break", unless it is preceded by two spaces or a backslash to make it a "hard break". soft breaks are rendered as spaces; hard breaks are rendered as line breaks.

MarkdownIt has a breaks=True option that renders softbreaks as a line break. I'd like that option on rich.markdown.Markdown too.

i'm thinking this is an easy "\n" if self.breaks else " " here:

rich/rich/markdown.py

Lines 613 to 616 in 349042f

elif node_type == "hardbreak":
context.on_text("\n", node_type)
elif node_type == "softbreak":
context.on_text(" ", node_type)

Copy link

Thank you for your issue. Give us a little time to review it.

PS. You might want to check the FAQ if you haven't done so already.

This is an automated reply, generated by FAQtory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant