~alcinnz/haskell-stylist

932c35860693c11f4d937fdb6428cc8709436770 — Adrian Cochrane 5 years ago 0dc35ad
Improve traverseStyles type signature.

Allow differing output types and give text nodes style if they want it.
1 files changed, 3 insertions(+), 3 deletions(-)

M stylish-html-conduit/src/Data/HTML2CSS.hs
M stylish-html-conduit/src/Data/HTML2CSS.hs => stylish-html-conduit/src/Data/HTML2CSS.hs +3 -3
@@ 60,8 60,8 @@ strContent (_:rest) = strContent rest
strContent [] = ""

---- Styling
traverseStyles :: PropertyParser s => (s -> [s] -> s) -> (Txt.Text -> s) -> 
        QueryableStyleSheet s -> XML.Element -> s
traverseStyles :: PropertyParser s => (s -> [o] -> o) -> (s -> Txt.Text -> o) ->
        QueryableStyleSheet s -> XML.Element -> o
traverseStyles = traverseStyles' Nothing temp Nothing
traverseStyles' parent parentStyle previous builder textBuilder stylesheet el@(
        XML.Element _ _ children


@@ 73,7 73,7 @@ traverseStyles' parent parentStyle previous builder textBuilder stylesheet el@(
        overrides = [] -- TODO

        traverseChildren prev (XML.NodeContent txt:nodes) =
            textBuilder txt : traverseChildren prev nodes
            textBuilder style txt : traverseChildren prev nodes
        traverseChildren prev (XML.NodeElement el:nodes) =
            traverseStyles' maybeEl style prev builder textBuilder stylesheet el :
                traverseChildren (Just $ elToStylish el maybeEl prev) nodes