git.iko.soy/typeable/pandoc
on master help sign in
SelfContained: omit content-type on type attribute for `<style>`.

It doesn't seem to be valid for HTML5, and as a result Chrome ignores the style element. Closes #5725.

commit0a3cc0be4563514c05a929844f729b46be508c5c authorJohn MacFarlane <jgm@berkeley.edu> dateTue 3 Sep 2019, 17:26 (7 years ago) parente463817
1 file changed+8−5
src/Text/Pandoc/SelfContained.hs+8−5
src/Text/Pandoc/SelfContained.hs+8−5
@@ -1,5 +1,6 @@
11{-# LANGUAGE NoImplicitPrelude #-}
22{-# LANGUAGE OverloadedStrings #-}
3+{-# LANGUAGE TupleSections #-}
34{- |
45 Module : Text.Pandoc.SelfContained
56 Copyright : Copyright (C) 2011-2019 John MacFarlane
@@ -112,7 +113,7 @@ convertTags (t@(TagOpen "link" as):ts) =
112113 rest <- convertTags $
113114 dropWhile (==TagClose "link") ts
114115 return $
115− TagOpen "style" [("type", mime)]
116+ TagOpen "style" [("type", "text/css")] -- see #5725
116117 : TagText (toString bs)
117118 : TagClose "style"
118119 : rest
@@ -210,12 +211,14 @@ handleCSSUrl d (url, fallback) =
210211 res <- lift $ getData "" url'
211212 case res of
212213 Left uri -> return $ Left (B.pack $ "url(" ++ uri ++ ")")
213− Right (mt, raw) -> do
214+ Right (mt', raw) -> do
214215 -- note that the downloaded CSS may
215216 -- itself contain url(...).
216− b <- if "text/css" `isPrefixOf` mt
217− then cssURLs d raw
218− else return raw
217+ (mt, b) <- if "text/css" `isPrefixOf` mt'
218+ -- see #5725: in HTML5, content type
219+ -- isn't allowed on style type attribute
220+ then ("text/css",) <$> cssURLs d raw
221+ else return (mt', raw)
219222 return $ Right (mt, b)
220223
221224getDataURI :: PandocMonad m => MimeType -> String -> m String