Skip to content

fix: strip <ol>-only attrs (start, type, reversed) from <li>/<dd>#187

Merged
dereuromark merged 3 commits into
masterfrom
fix/strip-ol-only-attrs-from-li
May 20, 2026
Merged

fix: strip <ol>-only attrs (start, type, reversed) from <li>/<dd>#187
dereuromark merged 3 commits into
masterfrom
fix/strip-ol-only-attrs-from-li

Conversation

@dereuromark

Copy link
Copy Markdown
Contributor

Summary

Strips three <ol>-only HTML attribute names — start, type, reversed — from the rendered <li> and <dd> output. These attributes are HTML-valid only on <ol>; when an author put them on a list item (e.g. via the postfix {start=5} line) they previously passed through to <li> and produced invalid HTML.

Before / after

Input:

1. item
   {start=5}

Before:

<ol>
<li start="5">
item
</li>
</ol>

After:

<ol>
<li>
item
</li>
</ol>

The legitimate way to set <ol start="5"> (a block-attribute line before the list) is unchanged.

Tests

Six new test methods in tests/TestCase/DjotConverterTest.php covering: start / type / reversed strip on <li>, pass-through of other attributes (class/id/data-*), start on <ol> from a block-attribute line still works, and <dd> parity.

Docs

Notes added under "List Item Attributes" and "Definition List Element Attributes" in docs/reference/enhancements.md.

Related

Part of the attribute-hardening sweep. Sibling: #186 (G2 list-item terminator fix, merged), #185 (marker-adjacent tracking).

Mark Scherer added 3 commits May 20, 2026 02:17
start, type, reversed are HTML attributes valid only on <ol>. When
authored on a list item (or <dd>) they currently pass through to
the <li>/<dd> tag, producing invalid HTML. These tests pin the
target behavior: silently strip those three names from <li>/<dd>
output while leaving class, id, data-*, etc. unchanged.
When an author puts start/type/reversed on a list item or <dd> (e.g.
via the postfix {start=5} attribute line), the HTML renderer
previously passed them through to <li>/<dd>, producing invalid HTML.
These attributes are valid only on <ol>, so silently strip them from
list-item / definition-description output. class, id, data-*, etc.
are unchanged. <ol> attributes derived from a preceding block-attr
line still emit normally.
@dereuromark dereuromark added the bug Something isn't working label May 20, 2026
@dereuromark dereuromark merged commit 7cd1cff into master May 20, 2026
4 checks passed
@dereuromark dereuromark deleted the fix/strip-ol-only-attrs-from-li branch May 20, 2026 00:23
@codecov

codecov Bot commented May 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.12%. Comparing base (d3050b3) to head (4d7114f).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master     #187   +/-   ##
=========================================
  Coverage     91.12%   91.12%           
  Complexity     3354     3354           
=========================================
  Files            99       99           
  Lines          8575     8575           
=========================================
  Hits           7814     7814           
  Misses          761      761           

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

dereuromark added a commit that referenced this pull request May 20, 2026
Documents the governing principle ("attributes precede their target;
adjacency selects the tighter target where supported") and a single
table covering all djot-php attribute targets (block, inline, <li>,
<dt>, <dd>, <dl>, table row, table cell, marker-glyph not-addressable
note). Notes the start/type/reversed strip on <li>/<dd> (#187) and
the list-item last-content-line rule (#186).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant