Skip to content

Add list item attribute support#5

Merged
dereuromark merged 1 commit intomasterfrom
feature/list-item-attributes
Nov 28, 2025
Merged

Add list item attribute support#5
dereuromark merged 1 commit intomasterfrom
feature/list-item-attributes

Conversation

@dereuromark
Copy link
Copy Markdown
Contributor

Summary

Adds support for attributes on list items, following the proposed syntax from jgm/djot#262.

Syntax:

- item 1
  {.highlight #id1}
- item 2
  {data-value="test"}

Output:

<ul>
<li class="highlight" id="id1">item 1</li>
<li data-value="test">item 2</li>
</ul>

Works with:

  • Unordered lists (-, *)
  • Ordered lists (1., a., i.)
  • Task lists (- [x], - [ ])

Implementation

  • Added parseAttributeStringToArray() method to return attributes without modifying $pendingAttributes
  • Modified tryParseList() to detect attribute blocks after list item content
  • Attribute lines must be indented at content level (same as continuation text)

Test plan

  • 5 new tests for list item attributes
  • All 539 existing tests pass
  • PHPStan level 8 passes
  • Code style passes

🤖 Generated with Claude Code

List items can now have attributes on the following line at content indent:

```djot
- item 1
  {.highlight #id1}
- item 2
  {data-value="test"}
```

Renders as:
```html
<li class="highlight" id="id1">item 1</li>
<li data-value="test">item 2</li>
```

Works with:
- Unordered lists
- Ordered lists
- Task lists

Related: jgm/djot#262

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Nov 28, 2025

Codecov Report

❌ Patch coverage is 86.20690% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.14%. Comparing base (a371cbb) to head (0fae4ed).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/Parser/BlockParser.php 86.20% 4 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master       #5      +/-   ##
============================================
- Coverage     92.19%   92.14%   -0.05%     
- Complexity     1377     1392      +15     
============================================
  Files            53       53              
  Lines          3549     3578      +29     
============================================
+ Hits           3272     3297      +25     
- Misses          277      281       +4     

☔ View full report in Codecov by Sentry.
📢 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.

@dereuromark dereuromark merged commit 0ef5f00 into master Nov 28, 2025
4 of 6 checks passed
@dereuromark dereuromark deleted the feature/list-item-attributes branch November 28, 2025 10:18
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