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

Added Support for Line Breaks in Inline Elements #168

Merged
merged 7 commits into from
Jan 7, 2025
Merged

Added Support for Line Breaks in Inline Elements #168

merged 7 commits into from
Jan 7, 2025

Conversation

jrg94
Copy link
Member

@jrg94 jrg94 commented Jan 6, 2025

Most markdown parsers support a line break feature as follows:

This line is separate from the following line  
This line is on its own line

As long as there are two spaces following the end of the first line, these two lines will render separately as follows:

This line is separate from the following line
This line is on its own line

The way this works is that markdown parsers will see the two spaces and interpret it as a line break. Therefore, the two spaces will be replaced with a line break tag (i.e., <br>).

To replicate this behavior in SnakeMD, I have added a line break feature to the Inline element. When the line break flag is True, a line break will be added at the end of the Inline element.

However, because the Paragraph element in SnakeMD removes all whitespace, we can't replicate the line break behavior exactly. As a result, rather than changing the behavior of the Paragraph element (given its potential widespread use), an HTML line break will be produced instead of two spaces.

I believe this falls in line with the expectations of this library anyway. After all, if the user wants to use markdown, there Raw element should allow them to do so.

@jrg94 jrg94 self-assigned this Jan 6, 2025
@jrg94 jrg94 added the enhancement New feature or request label Jan 6, 2025
@jrg94 jrg94 linked an issue Jan 6, 2025 that may be closed by this pull request
@jrg94 jrg94 merged commit c87bff6 into main Jan 7, 2025
15 checks passed
@jrg94 jrg94 deleted the linebreak branch January 7, 2025 02:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Break Line Inside Paragraph
1 participant