@@ 52,19 52,13 @@ import Foreign.C.String
import Data.ByteString (useAsCString)
renderDoc :: Style.QueryableStyleSheet (Style.VarParser (CSSTxt.TextStyle SpeechStyle)) -> XML.Element -> B.ByteString
-renderDoc style html =
- renderElLBS $ styleToSSML $ CSSTxt.resolve $ inlinePseudos' $ stylize style $ el2stylist html
-
-inlinePseudos' :: Style.PropertyParser s => StyleTree [(Text, Style.VarParser s)] -> StyleTree s
-inlinePseudos' (StyleTree self childs) = StyleTree {
- style = fromMaybe Style.temp $ Style.innerParser <$> lookup "" self,
- children = pseudo "before" ++ map inlinePseudos' childs ++ pseudo "after"
- } where
- pseudo n
- | Just style <- Style.innerParser <$> lookup n self,
- Just style' <- Style.longhand style style "::" [CSSTok.Ident n] = [StyleTree style' []]
- | Just style <- Style.innerParser <$> lookup n self = [StyleTree style []]
- | otherwise = []
+renderDoc style html = renderElLBS $ styleToSSML $ CSSTxt.resolve $
+ treeMap Style.innerParser $ stylize' style $ el2stylist html
+
+stylize' style = preorder inner
+ where
+ inner parent _ el = Style.cascade style el [] $
+ Style.inherit $ fromMaybe Style.temp parent
renderElLBS el = XML.renderLBS XML.def $ XML.Document {
XML.documentPrologue = XML.Prologue [] Nothing [],