From 27745b944c7299f6756758baf21dc3754b03103d Mon Sep 17 00:00:00 2001 From: Adrian Cochrane Date: Tue, 6 Aug 2019 19:09:57 +1200 Subject: [PATCH] Support multi-valued CSS content: properties. --- src/StyleTree.hs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/StyleTree.hs b/src/StyleTree.hs index 5cb8671..42e9f94 100644 --- a/src/StyleTree.hs +++ b/src/StyleTree.hs @@ -68,6 +68,13 @@ parseCue [Ident "none"] = Just NoCue parseCue _ = Nothing data StyleLeaf = Content {value :: Text} | Counter Text | Counters Text Text deriving Eq +parseContent (String txt:toks) = (\val -> Content txt : val) <$> parseContent toks +parseContent (Function "counter" : Ident c : LeftParen : toks) = + (\val -> Counter c : val) <$> parseContent toks +parseContent (Function "counters" : Ident c : Comma : String sep : LeftParen : toks) = + (\val -> Counters c sep : val) <$> parseContent toks +parseContent [] = Just [] +parseContent _ = Nothing parseCounters _ [Ident "none"] = Just [] parseCounters _ [] = Just [] @@ -201,10 +208,7 @@ instance Style.PropertyParser StyleTree where longhand _ self "cue-before" toks = (\val -> self {cueBefore = val}) <$> parseCue toks longhand _ self "cue-after" toks = (\val -> self {cueAfter = val}) <$> parseCue toks - longhand _ self "content" [String txt] = Just self {content = [Content txt]} - longhand _ self "content" [Function "counter", Ident c, LeftParen] = Just self {content = [Counter c]} - longhand _ self "content" [Function "counters", Ident c, Comma, String sep, LeftParen] = - Just self {content = [Counters c sep]} + longhand _ self "content" toks = (\val -> self {content = val}) <$> parseContent toks longhand _ self "counter-reset" toks = (\val -> self {counterReset = val}) <$> parseCounters 0 toks longhand _ self "counter-increment" toks = (\val -> self {counterIncrement = val}) <$> parseCounters 1 toks -- 2.30.2