fix: invalid inline-span attribute block stays literal#237
Merged
Conversation
A bracketed run abutting an attribute block always materialized a
<span> and then silently dropped any block that was not valid attribute
syntax. `[x]{???}` rendered as `<span>x</span>` with the `{???}` payload
lost.
Gate span formation (and consecutive attribute application) on a new
isValidAttrPayload(): a block forms/extends attributes only when it
yields an attribute or is empty/whitespace/comment-only. An invalid
block leaves the brackets and the block literal, with the bracket text
still inline-parsed, e.g. `[*x*]{???}` -> `[<strong>x</strong>]{???}`.
Empty/whitespace blocks ([x]{} / [x]{ }) still form a bare <span> so a
default-attribute extension can target it. Applies to spans, links, and
code spans via the shared applyConsecutiveAttributes().
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #237 +/- ##
============================================
- Coverage 91.89% 91.89% -0.01%
- Complexity 3523 3527 +4
============================================
Files 106 106
Lines 9958 9970 +12
============================================
+ Hits 9151 9162 +11
- Misses 807 808 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
What
A bracketed run directly abutting an attribute block always materialized a
<span>and then silently dropped any block that was not valid attribute syntax. The payload vanished:[x]{???}<span>x</span>[x]{???}[*x*]{???}<span><strong>x</strong></span>[<strong>x</strong>]{???}[x]{.a}{???}<span class="a">x</span><span class="a">x</span>{???}Fix
A new
isValidAttrPayload()gates both span formation andapplyConsecutiveAttributes(): a{...}block forms or extends attributes only when it yields an attribute, or is empty/whitespace/comment-only. A block carrying unrecognized content is not an attribute block, so the brackets and the block render literally (the bracket text is still inline-parsed). The change applies to spans, links, and code spans through the shared helper.Empty and whitespace-only blocks (
[x]{},[x]{ }) still form a bare<span>, kept soDefaultAttributesExtensioncan target it. Note djot keeps{=...=}highlight, so[x]{=y=}now correctly renders[x]<mark>y</mark>(the highlight was previously swallowed as a span attribute).Backport of markup-carve/carve-php#43, adapted to djot (which retains
{=...=}highlight and the empty-block span).Known limitation
An exotic
[x]{.a}{???}{.b}leaves the trailing{.b}to attach to the now-literal{???}via djot's standalone-attribute feature (text{.b}-><span class="b">text</span>), yielding<span class="a">x</span><span class="b">{???}</span>rather than fully-literal{???}{.b}. Suppressing that would mean conditionally disabling a separate, legitimate djot feature; out of scope for this fix.Tests
Added cases for the invalid-block-literal behavior and the preserved empty-block span. Full suite and official corpus green.