packages feed

xml-conduit-stylist 2.1.0.0 → 2.2.0.0

raw patch · 2 files changed

+17/−11 lines, 2 filesdep ~basedep ~stylist

Dependency ranges changed: base, stylist

Files

src/Data/HTML2CSS.hs view
@@ -2,7 +2,8 @@ -- | Bindings from `xml-conduit` to `haskell-stylist`. module Data.HTML2CSS(         html2css, cssPriorityAgent, cssPriorityUser, cssPriorityAuthor, -- parsing-        preorder, el2styletree, els2stylist, el2stylist, stylize, stylize', stylizeEl -- application+        preorder, el2styletree, els2stylist, el2stylist, stylize, stylize', stylizeEl, -- application+        inlinePseudos, stylizeNoPseudos, stylizeElNoPseudos     ) where  import qualified Data.List as L@@ -65,15 +66,6 @@  ---- Styling -preorder :: (Maybe b -> Maybe b -> a -> b) -> StyleTree a -> StyleTree b-preorder cb self = head $ preorder' cb Nothing Nothing [self]-preorder' :: (Maybe b -> Maybe b -> a -> b) ->-        Maybe b -> Maybe b -> [StyleTree a] -> [StyleTree b]-preorder' cb parent previous (self:sibs) = let self' = cb parent previous $ style self-        in StyleTree self' (preorder' cb (Just self') Nothing $ children self) :-            preorder' cb parent (Just self') sibs-preorder' _ _ _ [] = []- el2styletree el = StyleTree (Left el) $ mapMaybe node2styletree $ XML.elementNodes el node2styletree (XML.NodeElement el) = Just $ el2styletree el node2styletree (XML.NodeContent txt) = Just $ StyleTree (Right [("content", [String txt])]) []@@ -110,3 +102,17 @@         overrides = concat [fst $ parseProperties' $ tokenize $ Txt.pack val             | Attribute "style" _ val <- attributes el] stylizeEl stylesheet = stylize stylesheet . el2stylist++inlinePseudos :: PropertyParser s => StyleTree [(Txt.Text, VarParser s)] -> StyleTree s+inlinePseudos (StyleTree self childs) = StyleTree {+        style = fromMaybe temp $ innerParser <$> lookup "" self,+        children = pseudo "before" ++ map inlinePseudos childs ++ pseudo "after"+    } where+        pseudo n+            | Just style <- innerParser <$> lookup n self,+                Just style' <- longhand style style "::" [Ident n] = [StyleTree style' []]+            | Just style <- innerParser <$> lookup n self = [StyleTree style []]+            | otherwise = []++stylizeNoPseudos css = inlinePseudos . stylize css+stylizeElNoPseudos css = inlinePseudos . stylizeEl css
xml-conduit-stylist.cabal view
@@ -10,7 +10,7 @@ -- PVP summary:      +-+------- breaking API changes --                   | | +----- non-breaking API additions --                   | | | +--- code changes with no API change-version:             2.1.0.0+version:             2.2.0.0  -- A short (one-line) description of the package. synopsis:            Bridge between xml-conduit/html-conduit and stylist