Skip to content

feat: attach attributes to list items via marker-adjacent syntax (jgm/djot#262)#241

Merged
dereuromark merged 1 commit into
masterfrom
feature/list-item-marker-attributes
Jun 11, 2026
Merged

feat: attach attributes to list items via marker-adjacent syntax (jgm/djot#262)#241
dereuromark merged 1 commit into
masterfrom
feature/list-item-marker-attributes

Conversation

@dereuromark

Copy link
Copy Markdown
Contributor

Summary

Implements the djot proposal jgm/djot#262: attributes in curly braces that immediately follow a list marker (no space before the brace) attach to the <li> element.

+{.blue} A blue list item.
+{#id1 .highlight} Item with id and class.
1.{data-value="test"} Numbered item with a data attribute.

renders as:

<ul>
<li class="blue">A blue list item.</li>
<li id="id1" class="highlight">Item with id and class.</li>
</ul>
<ol>
<li data-value="test">Numbered item with a data attribute.</li>
</ol>

Details

  • Works across every marker type: bullet (-/*/+), ordered numeric (1./1)), parenthesized ((1)/(a)), roman, alpha, and task lists.
  • Adjacency rule: a space before the brace changes the meaning. + {.blue} keeps the brace as item content (a block attribute for the following block inside the item), it does not attach to the <li>.
  • The older separate-indented-line form ({...} on its own line under the item) is soft-deprecated but still attaches to the <li> for back-compat. Marker attributes seed the item; the separate-line form merges on top.
  • The opt-in blocksInterruptParagraphs mode now recognizes the attributed markers, so -{.x} item / 1.{.x} item interrupt an open paragraph exactly like their plain counterparts.

Implementation

  • ListParser::parseListItemMarker() captures an optional {...} block immediately after each marker and returns it in a new attrs key.
  • BlockParser seeds the list item's attributes from attrs, and excludes the attribute width from the ordered-list content-indent column so multi-line attributed items keep the correct continuation indent.
  • The letter-marker fast-path gate and the paragraph-interruption detector both accept the optional adjacent {...}.

Docs

docs/guide/syntax.md now leads with the marker-adjacent syntax and marks the separate-line form as soft-deprecated.

Support the djot proposal jgm/djot#262: attributes in curly braces that
immediately follow a list marker (no space before the brace) attach to the
<li> element, e.g.

    +{.blue} A blue list item.
    (a){.bar} Ordered list item with an attribute.
    1.{data-value="test"} Numbered item with a data attribute.

Works across every marker type (bullet, ordered numeric, parenthesized,
roman, alpha, and task lists). A space before the brace keeps the old
meaning, the {...} is item content and acts as a block attribute for the
following block inside the item.

The previous separate-indented-line form is soft-deprecated but still
attaches to the <li> for back-compat; marker attributes seed the item and
the separate-line form merges on top.

Also teach the opt-in blocksInterruptParagraphs mode to recognize the
attributed markers so they interrupt an open paragraph just like the plain
markers do.
@codecov

codecov Bot commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.07692% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 91.89%. Comparing base (f80b8da) to head (bbeb295).

Files with missing lines Patch % Lines
src/Parser/BlockParser.php 93.75% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master     #241   +/-   ##
=========================================
  Coverage     91.89%   91.89%           
- Complexity     3527     3532    +5     
=========================================
  Files           106      106           
  Lines          9970     9985   +15     
=========================================
+ Hits           9162     9176   +14     
- Misses          808      809    +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dereuromark dereuromark merged commit fb5d8e3 into master Jun 11, 2026
6 checks passed
@dereuromark dereuromark deleted the feature/list-item-marker-attributes branch June 11, 2026 13:47
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.

1 participant