russross / blackfriday

Blackfriday: a markdown processor for Go
Other
5.45k stars 602 forks source link

Fix trailing <br>s added in lists with EXTENSION_HARD_LINE_BREAK enabled #686

Open thebaer opened 3 years ago

thebaer commented 3 years ago

Previously, with EXTENSION_HARD_LINE_BREAK enabled, <li>s would contain unnecessary <br />s at the end of each item. It was especially noticeable by the vertical space this left following an ordered or unordered list.

This fixes that by also stripping trailing <br />s from individual list items when this extension is enabled.

One shortcoming of this patch: it does not completely fix the issue in nested lists, as far as the markup goes -- but the visual issues are gone, at least. I can work on fully fixing the markup if there's interest in that.

Input:

* One
* Two

Paragraph
Previous ResultFixed Result
<ul>
<li>One<br /></li>
<li>Two<br />
<br /></li>
</ul>
 
<p>Paragraph</p>
<ul>
<li>One</li>
<li>Two</li>
</ul>
 
<p>Paragraph</p>