From 3efc7613f9d5eb953c97585f161624d091ffe884 Mon Sep 17 00:00:00 2001 From: Adrian Cochrane Date: Thu, 4 May 2023 13:15:46 +1200 Subject: [PATCH] Improve reliability of incrementing list-item counter; release 2.6! --- ChangeLog.md | 5 +++++ src/Data/CSS/Preprocessor/Text.hs | 9 +++++++-- stylist.cabal | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 00a022c..f82a932 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,10 @@ # Revision history for stylist +## 2.6.0 -- 2023-05-04 +* Improved text generation +* Added infrastructure forwarding pseudoelements to PropertyParsers +* @counter-style support, with large builtin suite. + ## 2.4.0 -- 2020-12-31 * Add `@document regexp()` support via TDFA. * Allow callers to define psuedoclasses via callbacks on attribute value. diff --git a/src/Data/CSS/Preprocessor/Text.hs b/src/Data/CSS/Preprocessor/Text.hs index 0e62675..6537a64 100644 --- a/src/Data/CSS/Preprocessor/Text.hs +++ b/src/Data/CSS/Preprocessor/Text.hs @@ -110,8 +110,7 @@ instance PropertyParser p => PropertyParser (TextStyle p) where Just self { isListItem = True, inner = fromMaybe self' $ - longhand (inner p) self' "display" [Ident "block"], - counterIncrement = insertList "list-item" 1 $ counterIncrement self + longhand (inner p) self' "display" [Ident "block"] } longhand TextStyle {inner=p'} self@TextStyle {inner = self'} "display" value | Just ret <- longhand p' self' "display" value = Just self { @@ -256,6 +255,12 @@ insertPseudos store (StyleTree self childs) = addBullet :: PropertyParser p => StyleTree (TextStyle p) -> CounterStore -> Maybe CounterStyle -> [Token] -> StyleTree (TextStyle p) +addBullet (StyleTree self@TextStyle { + counterIncrement = counters, isListItem = True + } childs) store cstyle txt | Nothing <- lookup "list-item" counters = + addBullet (StyleTree self { + counterIncrement = ("list-item", 1):counterIncrement self + } childs) store cstyle txt addBullet (StyleTree self@TextStyle { isListItem = True, listPosInside = True, markerPseudo = Just child } childs) store cstyle txt = insertPseudos store $ diff --git a/stylist.cabal b/stylist.cabal index dc75a0d..dc78855 100644 --- a/stylist.cabal +++ b/stylist.cabal @@ -10,7 +10,7 @@ name: stylist -- PVP summary: +-+------- breaking API changes -- | | +----- non-breaking API additions -- | | | +--- code changes with no API change -version: 2.5.0.0 +version: 2.6.0.0 -- A short (one-line) description of the package. synopsis: Apply CSS styles to a document tree. -- 2.30.2