Skip to content

Fix: Skip emphasis parsing when inside link#29

Open
Aaaaash wants to merge 2 commits into
thetarnav:mainfrom
Aaaaash:fix/skip-emphasis-parsing-when-inside-link
Open

Fix: Skip emphasis parsing when inside link#29
Aaaaash wants to merge 2 commits into
thetarnav:mainfrom
Aaaaash:fix/skip-emphasis-parsing-when-inside-link

Conversation

@Aaaaash

@Aaaaash Aaaaash commented Jul 14, 2025

Copy link
Copy Markdown

Considering we have a link with an underscore like this:

[read_md.md](https://github.com/thetarnav/streaming-markdown)

We might mistakenly parse the _ in the link as an underscore mark, resulting in incorrect insertion of <em> tags in the link.

We would end up with a link formatted like this:

readmd.md](https://github.com/thetarnav/streaming-markdown)

Its DOM structure would resemble:

<a>read<em>md.md](https://github.com/thetarnav/streaming-markdown))</em></a>

image

This Pull Request fixes the issue by skipping underscore parsing when encountering _ while the current token is a link.

@thetarnav

Copy link
Copy Markdown
Owner

text_with_underline
^
it’s not even specific to links
underscores in words shouldn’t be matched
they probably should require a whitespace before

@mvshmakov

Copy link
Copy Markdown

We are also faced with the same problem, would be cool to see this available in the upstream

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants