Repository navigation
Add list marker styles, reversed, value, ::marker and the list-item counter, and draw quotation marks for <q> #611
Copy link
Copy link
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Part of #552 (step 28, missing support, medium priority).
List markers and quotation marks cover only part of CSS:
list-style-typeknows about 30 values. The rest (decimal-leading-zero,upper-greek,armenian,georgian,hiragana,katakana,disclosure-openand string markers such as"→ ") fall back todecimal.<ol reversed>and<li value>are ignored.::markerrules are dropped.- The list counter cannot be set from CSS, because
counter-resetandcounter-incrementare never read. <q>draws no quotation marks, andquotesis never read.
Legal documents, contracts and numbered clauses use these.
Measured on gravitypdf at 60b82630, PHP 8.5.4, from the text handed to Cell().
| Document | Browser | mPDF |
|---|---|---|
<ol style="list-style-type:decimal-leading-zero"><li>a</li></ol> |
01. |
1. |
<ol style="list-style-type:upper-greek"><li>a</li><li>b</li></ol> |
Α. Β. |
1. 2. |
<ol style="list-style-type:armenian"><li>a</li></ol> |
Ա. |
1. |
<ul style="list-style-type:'→ '"><li>str</li></ul> |
→ str |
1. |
<ol reversed><li>r1</li><li>r2</li></ol> |
2. 1. |
1. 2. |
<ol><li value="7">v</li></ol> |
7. |
1. |
<ol style="counter-reset:list-item 4"><li>a</li></ol> |
5. |
1. |
li::marker { color: red } |
red markers | black |
<p><q>qq</q></p> |
“qq” |
qq |
<p style="quotes:'«' '»'"><q>qq</q></p> |
«qq» |
qq |
<ol start="3"> |
3. |
3. (works) |
Cause.
NormalizeProperties::processListStyleProperty()finds the type by searching the value for one of a fixed list of names (src/Css/NormalizeProperties.php:1021), sodecimal-leading-zerois read asdecimal._getStyledNumber()(src/Mpdf.php:12837) formats the numbers, and_setListMarker()(:16490) builds the marker.BlockTagreads<ol start>(src/Tag/BlockTag.php:146-147,:952-953) and nothing else from the list or item.- Selectors with a pseudo-element are dropped (A descendant rule with a part mPDF cannot match is applied to the element its first parts name #521).
Qis an emptyInlineTag(src/Tag/Q.php).
Fix.
- List types.
- Add
decimal-leading-zero,upper-greek,armenian,georgian,hiragana,katakana,hiragana-iroha,katakana-iroha,lower-armenian,disclosure-openanddisclosure-closedto_getStyledNumber()and the marker code. Each is a short table or a fixed algorithm from CSS Counter Styles. - Accept a string as a marker.
- Match the type as a whole keyword, not a substring.
- Add
- List attributes.
<ol reversed>counts down from the number of items; withstart, fromstart.<li value>sets the counter for that item and the ones after it. - Counters. Read
counter-reset,counter-setandcounter-incrementfor thelist-itemcounter only, which is what<ol start>,reversedandvaluemap onto. Named counters need generated content (::before,::after), which Support more CSS selectors and apply CSS rules by specificity #520 lists as not planned. ::marker. Matchli::marker(and::markerafter any list-item selector) as a pseudo-element of the item. Applycolor, thefont-*properties andcontent(a string) to the marker only.- Quotes.
<q>draws an opening and a closing quote fromquotes(inherited), nesting to the next pair for a<q>inside a<q>.- Without
quotes, use the pair for the element'slang, as browsers do:“ ”and‘ ’in English,« »in French,„ “in German, and so on. - The marks are real characters in the text, so they are copied and read aloud, and the PDF/UA tagging has to include them.
Tests. Each row above, a list in a table cell, an rtl list with upper-greek, reversed with start, ::marker on a nested list, nested <q> in English and German, and quotes: none.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request
Activity