snarkdown
snarkdown copied to clipboard
Links inside bold/italic text result in invalid HTML
Links inside runs of bold or italic text are rendered as invalid HTML.
For example, the following Markdown:
foo **[link](https://example.com)** bar
is rendered as:
foo <strong><a href="https://example.com">link</strong></a><strong> bar</strong>
whilst the expected output would be:
foo <strong><a href="https://example.com">link</a></strong> bar
Two things are unexpected here:
- The output is invalid because the
<strong>and<a>tags are closed in the same order in which they're opened. - The
<strong>tag is then re-opened and not closed until the end of the text, causing more of the text to be bold than intended.
The same happens when using __ instead of **, as well as with italics (_ or *).
When the formatting is inside the link, the result is as expected:
foo [**link**](https://example.com) bar
This renders as:
foo <a href=\"https://example.com\"><strong>link</strong></a> bar