Repository navigation
fix(html): number ordered list items by their type, reversed and value attributes - #4900
morten-lagabote wants to merge 1 commit into
Conversation
…e attributes
The HTML backend numbered the items of an `<ol>` only from its `start`
attribute. A list with `type="a"`, `"A"`, `"i"` or `"I"`, or with the same
kind of marker set by a `list-style-type` keyword in its inline style, got
decimal numbers. A `reversed` list counted up, and the `value` attribute of
an `<li>` had no effect. Legal texts refer to list items by their letter
("bokstav a"), so the letters were lost.
The marker of each item now follows the ordinal values of the HTML
specification and the counter styles that browsers render. A list without
these attributes is unchanged.
Signed-off-by: Morten Dæhli Aslesen <morten@lagabote.no>
|
✅ DCO Check Passed Thanks @morten-lagabote, all your commits are properly signed off. 🎉 |
Merge Protections🟢 Merge protection satisfied — ready to merge. Show 1 satisfied protection🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
AI triage (advisory)Checked commit The HTML backend now numbers Topic labels added: CI safety: no concern found. A maintainer must still approve CI. 2 related pull request(s) in the same code
The |
There was a problem hiding this comment.
AI first review (advisory): no blocker found
This review covers the full diff at b441869591. It read the code and did not run it.
The PR adds letter, Roman numeral, reversed, and value marker support to the HTML ordered-list backend. The logic is self-consistent and the new test covers boundary values, interrupted lists, and fallback to decimal. No regressions are visible from code inspection: plain <ol> without attributes follows the same code path as before (start=None, ordinal=None, marker ""), and decimal <ol start="N"> produces the same result via _format_ol_marker(ordinal, "1"). The one deviation from the HTML spec — negative <li value> is ignored — is stated in the PR description and matches the existing start behavior.
A maintainer makes the merge decision. This review never approves the pull request.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
The HTML backend numbered the items of an
<ol>from itsstartattribute only. The kind of marker was lost, so lettered and Roman-numbered lists got decimal numbers.The marker of each item now follows the ordinal value of the item and the kind of marker of the list:
typeattribute (1,a,A,i,I), or from alist-style-typekeyword in the inline style of the<ol>(decimal,lower-alpha,lower-latin,upper-alpha,upper-latin,lower-roman,upper-roman). The inline style wins, as in browsers. In the new helper_format_ol_marker, letters countatoz, thenaa,ab, and Roman numerals cover 1 to 3999, as the CSS counter styles. Outside that range, the marker is decimal.reversedlist counts down, by default from its number of items.valueattribute of an<li>sets the number of the item, and the items after it continue from it. The value is parsed with_parse_ol_start(fix(html): parse the start of an ordered list by the HTML rules for integers #4713), so a negative value is ignored, as a negativestart.A list without these attributes is unchanged: its items keep an empty marker. In Markdown, a letter or Roman numeral is written as
- a. first, as the serializer writes other markers that are not decimal.Issue resolved by this Pull Request:
Resolves #4899
Checklist:
Review evidence:
main7a25855) / after, on the public documents of HTML backend: lettered and Roman-numbered lists get decimal numbers #4899:1.,2., ... before. After, they have the letters and Roman numerals that Chrome shows. Nothing else changes in the Markdown export.type="a"are numbered1.,2., ... before, anda.,b., ... after. Nothing else changes in the Markdown export.start(alsotype="1", an unknowntypeandlist-style-type: decimal): Docling keeps an empty marker, and the Markdown serializer numbers the items.value: Chrome counts from it, Docling from 1, as for a negativestart.<ul>, and keywords such aslower-greek: not supported.test_ordered_list_item_marker_from_attributes(12 cases). 11 cases fail without the fix.