Skip to content

Odd/Even number of underscores in markdown tags treated as emphasis/strong #582

@askmrsinh

Description

@askmrsinh

I am trying to convert the below markdown text to html.

Input Markdown Image and link tags with odd (3) number of _:

![alt-assets/Wetter___stats.jsp.png](https://gitlab.com/user501254/Wetter/raw/b80b165a57036319d80d3e59919c3fa1a4719eb7/assets/Wetter___stats.jsp.png)

[alt-assets/Wetter___stats.jsp.png](https://gitlab.com/user501254/Wetter/raw/b80b165a57036319d80d3e59919c3fa1a4719eb7/assets/Wetter___stats.jsp.png)

The above should ideally be convert to below HTML:

<p><img src="https://gitlab.com/user501254/Wetter/raw/b80b165a57036319d80d3e59919c3fa1a4719eb7/assets/Wetter___stats.jsp.png" alt="assets/Wetter___stats.jsp.png" /></p>

<p><a href="https://gitlab.com/user501254/Wetter/raw/b80b165a57036319d80d3e59919c3fa1a4719eb7/assets/Wetter___stats.jsp.png">assets/Wetter___stats.jsp.png</a></p>

However, output (-o kramdown) with incorrectly place *:

\[assets/Wetter\_\_*stats.jsp.png\](https://gitlab.com/user501254/Wetter/raw/b80b165a57036319d80d3e59919c3fa1a4719eb7/assets/Wetter*\_\_stats.jsp.png)

!\[assets/Wetter\_\_*stats.jsp.png\](https://gitlab.com/user501254/Wetter/raw/b80b165a57036319d80d3e59919c3fa1a4719eb7/assets/Wetter*\_\_stats.jsp.png)

Furthermore, instead of 3 (odd) underscores (___) if there are 4 (even > 2) underscores (____) it's parsed as as **. As we increase the count of underscores, both <em> and <strong> tags start showing up in the output without a corresponding closing tag (</em>, </strong>).
Manually escaping the underscores in both the cases fixes the issues.

I have checked the same input in some other converters (including this GitHub markdown field) where they are converted perfectly. Since I have almost no experience with the ruby code base, I am unable to make a PR with the fix but will be adding the test cases.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions