You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 63bcecc
Browse filesBrowse the repository at this point in the historyBrowse files
Match selectors that write an id with classes, such as p#i.c
`p#i.c`, `p.c#i`, `#i.c` and `p.a.b#i` never matched: the `.` and `#`
shapes took anything after the dot or hash, so `p.c#i` was stored as
class `C#I` and `p#i.c` as id `I.C`, names no element has.
A part made of an optional tag and any mix of classes and one id is now
parsed into one key, the tag, then the id, then the classes sorted, so
`p.c#i` and `p#i.c` are both `P>>ID>>I>>CLASS>>C`. Those keys are looked
up after `tag#id`, for each combination of the element's classes `#id.class`
then `tag#id.class`, in the simple groups, in descendant rules and when
an ancestor's rules are lifted.
Class and id names are limited to name characters, so a part such as
`.a:hover` or `#i::before` fails to parse and the selector is dropped,
as other selectors mPDF cannot match are.
Closes#527
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: CHANGELOG-GRAVITYPDF.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -91,6 +91,10 @@ New features
91
91
* Text beside a float, and the blocks around it, keep to the page area of each page the float runs over. [#549]
92
92
* A block with a set width keeps its place in each page area: a centred block stays centred, and a block pushed right by `margin-left: auto` or set right to left stays against the right margin. [#550][#551][#553]
93
93
94
+
### CSS
95
+
96
+
***An id written with classes.** Selectors such as `p#note.warning`, `p.warning#note`, `#note.warning` and `p.a.b#note` match, on their own and as parts of descendant rules, in any order of id and classes. They are applied after `p#note`. A selector with a class or id followed by something mPDF cannot match, such as `.a:hover` or `#note::before`, is dropped like any other selector mPDF cannot match. [#527][#568]
97
+
94
98
Performance
95
99
-----------
96
100
@@ -720,6 +724,7 @@ These changes do not change output.
} elseif (preg_match('/^(' . $this->mpdf->allowedCSStags . ')\s*:NTH-CHILD\(([\-+]?\d*N(?:[\-+]\d+)?|[\-+]?\d+|ODD|EVEN)\)$/', $t, $m)) { // the whole argument is a formula, with nothing after it
} elseif (preg_match('/^(' . $this->mpdf->allowedCSStags . '):LANG\([\'\"]{0,1}([A-Z\-]{2,11})[\'\"]{0,1}\)$/', $t, $m)) { // mPDF 6 Special case for lang as attribute selector
@@ -104,6 +100,44 @@ public function parseSimpleSelector($tags)
104
100
return$tag ?: null;
105
101
}
106
102
103
+
/**
104
+
* The key for a tag, id and classes written as one part, such as P#I.C or .B.A: the tag, then the id, then the
105
+
* classes in alphabetical order, so P.C#I and P#I.C give the same key, P>>ID>>I>>CLASS>>C
106
+
*
107
+
* @param string $tag The tag, or an empty string
108
+
* @param string $names The id and classes, each with its # or .
109
+
* @return string|null Null for two different ids, which no element has
0 commit comments