M src/Data/CSS/Syntax/StyleSheet.hs => src/Data/CSS/Syntax/StyleSheet.hs +3 -1
@@ 1,7 1,9 @@
module Data.CSS.Syntax.StyleSheet (
- parse, TrivialStyleSheet(..),
+ parse, parse', TrivialStyleSheet(..),
StyleSheet(..), skipAtRule,
StyleRule(..),
+ -- For parsing at-rules, HTML "style" attribute, etc.
+ parseProperties, parseProperties',
-- for testing
scanValue
) where
M stylish-haskell.cabal => stylish-haskell.cabal +1 -1
@@ 10,7 10,7 @@ name: stylish-haskell
-- PVP summary: +-+------- breaking API changes
-- | | +----- non-breaking API additions
-- | | | +--- code changes with no API change
-version: 0.2.2
+version: 0.3.0
-- A short (one-line) description of the package.
synopsis: Apply CSS styles to a document tree.
M stylish-html-conduit/src/Data/HTML2CSS.hs => stylish-html-conduit/src/Data/HTML2CSS.hs +5 -2
@@ 12,6 12,7 @@ import qualified Data.Text as Txt
import qualified Text.XML as XML
import Data.CSS.Syntax.StyleSheet
import Data.CSS.Style
+import Data.CSS.Syntax.Tokens (tokenize)
import Network.URI
@@ 64,13 65,15 @@ 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
+ XML.Element _ attrs children
) = builder style $ traverseChildren Nothing children
where
stylishEl = elToStylish el parent previous
maybeEl = Just stylishEl
style = cascade stylesheet stylishEl overrides parentStyle
- overrides = [] -- TODO
+ overrides | Just styleAttr <- "style" `M.lookup` attrs =
+ fst $ parseProperties' $ tokenize styleAttr
+ | otherwise = []
traverseChildren prev (XML.NodeContent txt:nodes) =
textBuilder style txt : traverseChildren prev nodes
M stylish-html-conduit/stylish-html-conduit.cabal => stylish-html-conduit/stylish-html-conduit.cabal +2 -2
@@ 10,7 10,7 @@ name: stylish-html-conduit
-- PVP summary: +-+------- breaking API changes
-- | | +----- non-breaking API additions
-- | | | +--- code changes with no API change
-version: 0.1.0.0
+version: 0.1.0.1
-- A short (one-line) description of the package.
synopsis: Bridge between html-conduit and stylish-haskell
@@ 61,7 61,7 @@ library
-- Other library packages from which modules are imported.
build-depends: base >=4.9 && <4.10,
- stylish-haskell >= 0.2.2,
+ stylish-haskell >= 0.3.0, css-syntax,
xml-conduit, text, containers,
network-uri