~alcinnz/haskell-stylist

3efc7613f9d5eb953c97585f161624d091ffe884 — Adrian Cochrane 11 months ago 5cc97dd
Improve reliability of incrementing list-item counter; release 2.6!
3 files changed, 13 insertions(+), 3 deletions(-)

M ChangeLog.md
M src/Data/CSS/Preprocessor/Text.hs
M stylist.cabal
M ChangeLog.md => ChangeLog.md +5 -0
@@ 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.

M src/Data/CSS/Preprocessor/Text.hs => src/Data/CSS/Preprocessor/Text.hs +7 -2
@@ 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 {


@@ 257,6 256,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 $
        StyleTree self { isListItem = False } (t cstyle child {

M stylist.cabal => stylist.cabal +1 -1
@@ 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.