Closed
Conversation
Emphasis delimiter scanning in parseDelimited() now skips over link underscores (or stars) inside link URLs from being treated as emphasis closers. Fixes #70 See also: jgm/djot#375
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #80 +/- ##
============================================
+ Coverage 93.42% 93.77% +0.35%
- Complexity 1956 2144 +188
============================================
Files 74 77 +3
Lines 5246 5719 +473
============================================
+ Hits 4901 5363 +462
- Misses 345 356 +11 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This was referenced Feb 8, 2026
dereuromark
added a commit
that referenced
this pull request
Feb 9, 2026
Simpler alternative to PR #80 that only protects delimiters inside link destinations `](...)`, without the full link lookahead. Problem: Emphasis delimiters (`_`, `*`) inside link destinations were matched as closers, breaking link formation: `_[link](http://example.com?foo_bar=1), more text_` → `<em>[link](http://example.com?foo</em>bar=1), more text_` Fix: When scanning for emphasis closers in `parseDelimited()`, skip over link destinations by detecting `](` and finding the matching `)`. This prevents delimiters inside URLs from closing emphasis. This is a targeted fix for the common real-world issue (URLs with underscores in query parameters). It intentionally does NOT fix the bracket-text case (`_[foo_](url)`) which remains emphasis - this keeps the implementation simple per discussion in jgm/djot#375. Refs: jgm/djot#375
Contributor
Author
|
Closing in favor of #80 - keeping to the specs should be preferred. |
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.
Fixes #70
Upstream: jgm/djot#375
Problem
Emphasis delimiter scanning in
parseDelimited()treats underscores/stars inside link URLs as emphasis closers:jgm confirmed this is a spec-level bug that should be fixed.
Fix
Added a
findLinkEnd()helper (following the same pattern as existingfindCodeSpanEnd()/findAutolinkEnd()) thatparseDelimited()calls when it encounters[or,[text][ref], and image variants, preventing delimiters inside URLs from interfering with emphasis matching.Changed test expectations
Two official test expectations were updated to reflect the corrected behavior:
emphasis.testFix converter blank line handling between block elements #29:_[bar_](url)— link now forms instead of emphasislinks_and_images.testImprove MarkdownToDjot round-trip conversion with HTML tag support #19:*[closed](hello*)— link now forms instead of strongThese will need to be synced once jgm updates the upstream spec tests.