Skip to content

add blank line before/after preformatted blocks #179

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

Conversation

chrispy-snps
Copy link
Collaborator

Fixes the preformatted block part of #176.

A blank line is inserted before and after preformatted blocks. Unit tests are updated.

For example, this:

import markdownify

md = markdownify.MarkdownConverter().convert

print(md(html="1<pre>2</pre>3<pre>4</pre>5"))

results in this:

1

```
2
```

3

```
4
```

5

@chrispy-snps chrispy-snps requested a review from AlexVonB January 19, 2025 16:10
@chrispy-snps
Copy link
Collaborator Author

@AlexVonB - I requested a review.

This change is subjective - most Markdown parsers will handle preformatted blocks with content lines directly adjacent to the fence lines. However, that style can be visually disconcerting for humans to read.

In my opinion, the improved readability is worth the extra two characters per preformatted element. (After all, isn't the purpose of Markdown to be a structural format that is also human-friendly?)

Signed-off-by: chrispy <chrispy@synopsys.com>
@chrispy-snps chrispy-snps force-pushed the chrispy/add-blank-lines-around-pre branch from c3441d7 to 05846c2 Compare January 19, 2025 16:15
@chrispy-snps chrispy-snps changed the title add blank line before/after preformatted block add blank line before/after preformatted blocks Jan 19, 2025
Copy link
Collaborator

@AlexVonB AlexVonB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as with #178, lgtm but we need to keep the general whitespace in mind. Thanks for tackling this! :)

@chrispy-snps chrispy-snps merged commit dbb5988 into matthewwithanm:develop Jan 21, 2025
1 check passed
@chrispy-snps chrispy-snps deleted the chrispy/add-blank-lines-around-pre branch February 17, 2025 13:45
Wuhall pushed a commit to Wuhall/python-markdownify that referenced this pull request May 21, 2025
Signed-off-by: chrispy <chrispy@synopsys.com>
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