Skip to content

Fix: Skip emphasis parsing when inside link#29

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

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

Conversation

@Aaaaash
Copy link

@Aaaaash Aaaaash commented Jul 14, 2025

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
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

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.

2 participants