fix: handleincompletesingleunderscoreitalic is not accounting for the usage inside math equations#38
Merged
haydenbleasel merged 2 commits intomainfrom Aug 25, 2025
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
own-boldsbrain
pushed a commit
to own-boldsbrain/streamdown
that referenced
this pull request
Sep 22, 2025
… usage inside math equations (vercel#38) * Fix underscores in math equations * Create cuddly-goats-warn.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request addresses a bug in the markdown parser related to handling single underscores used for italics when they appear inside math equations. The core improvement ensures that underscores inside math blocks (delimited by$...$ `) are not incorrectly interpreted as markdown italics, while underscores outside math blocks continue to be handled as before. Comprehensive tests have been added to verify correct behavior for various edge cases in math and markdown parsing.
$... orBug fix for markdown parsing in math blocks:
countSingleUnderscoreswithinparse-incomplete-markdown.tsto skip underscores that are inside math blocks, using a new helper functionisWithinMathBlock. This prevents underscores inside$... orisWithinMathBlockto detect whether a character position is inside an inline or block math region, correctly handling escaped dollar signs and precedence between inline and block math.Expanded test coverage:
parse-incomplete-markdown.test.tsto verify that underscores inside math blocks are not completed as italics, while underscores outside math blocks are handled normally. The tests cover inline math, block math, incomplete math blocks, mixed content, and escaped dollar signs.Documentation and changelog: