Skip to content

Commit

Permalink
Handle adding <br> smartly
Browse files Browse the repository at this point in the history
  • Loading branch information
TanmayPatil105 committed Jun 19, 2024
1 parent bf21892 commit 7d2e6b8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/html.c
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,16 @@ post_format (HTMLFile *file,

unit = html->html[index];

if (!tag_is_heading (unit->tag) &&
!tag_is_code_block (unit->tag))
/*
* Do not add <br>
* 1. after a heading
* 2. inside a code block
* 3. if previous element was a heading
*
*/
if (!(tag_is_heading (unit->tag) ||
tag_is_code_block (unit->tag) ||
((index != 0) && tag_is_heading (html->html[index - 1]->tag))))
INSERT_LINEBREAK (file);

if (unit->tag == HTML_TAG_LI &&
Expand Down
1 change: 1 addition & 0 deletions tests/quote.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

> This is a quote
> This is another quote
Not a quote

0 comments on commit 7d2e6b8

Please sign in to comment.