russross / blackfriday

Blackfriday: a markdown processor for Go
Other
5.41k stars 596 forks source link

Is it possible to not wrap <div> inside <a> in <p> #687

Open inliquid opened 3 years ago

inliquid commented 3 years ago

As of HTML 5 wrapping block element in <a> is valid HTML.

However this renderer breaks a construction with <a> links, because they will be wrapped in <p>:

MD input:

<a href="/asset/upload/post/2713/789f4b70fb52b581274758966463dd7b.zip" target="_blank"><div class="file-icon file-icon-xl" data-type="zip"></div></a>

HTML output:

<p><a href="/asset/upload/post/2713/789f4b70fb52b581274758966463dd7b.zip" target="_blank" rel="nofollow noopener"><div class="file-icon file-icon-xl" data-type="zip"></div></a></p>

And as a result browser will break everything by parsing it as:

<p><a href="/asset/upload/post/2713/789f4b70fb52b581274758966463dd7b.zip" target="_blank" rel="nofollow noopener"></a></p><div class="file-icon file-icon-xl" data-type="zip"></div><p></p>

Is there a way to make renderer not add <p> around <div> inside <a>?