fix(parser): Protect inline code from formatting while allowing spans #6
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 fixes issue #2. Previously, links, bold, and italic HTML was sometimes incorrectly applied to inline code containing a special character. For example,
__init__should not be bolded, but it currently is.At the same time, formatting that spans across inline code should still be applied. The fix is to replace code blocks with a unique placeholder that is unlikely to appear in the text.
This PR replaces each code block with indexed private use area unicode (
\uE000{index}\uE001) and then applies link, bold, and italic formatting. When finished, the placeholder is replaced with the corresponding code block.(The PR includes comprehensive test coverage for edge cases including nested formatting, multiple code blocks, and complex spanning scenarios)
Before:
After:
Summary by cubic
Protects inline code from being formatted while still allowing bold/italic/link spans across code. Fixes incorrect styling like init being bolded inside code (fixes #2).