feat: attach attributes to list items via marker-adjacent syntax (jgm/djot#262)#241
Merged
Merged
Conversation
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 Report❌ Patch coverage is
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. 🚀 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.
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.renders as:
Details
-/*/+), ordered numeric (1./1)), parenthesized ((1)/(a)), roman, alpha, and task lists.+ {.blue}keeps the brace as item content (a block attribute for the following block inside the item), it does not attach to the<li>.{...}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.blocksInterruptParagraphsmode now recognizes the attributed markers, so-{.x} item/1.{.x} iteminterrupt an open paragraph exactly like their plain counterparts.Implementation
ListParser::parseListItemMarker()captures an optional{...}block immediately after each marker and returns it in a newattrskey.BlockParserseeds the list item's attributes fromattrs, and excludes the attribute width from the ordered-list content-indent column so multi-line attributed items keep the correct continuation indent.{...}.Docs
docs/guide/syntax.mdnow leads with the marker-adjacent syntax and marks the separate-line form as soft-deprecated.