From ef7b769fa07e2cbf4e9b8004484828628f548409 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 21 Oct 2021 21:51:53 -0700 Subject: SelfContained: fix bug that caused everything to be made a data uri. All the code we needed to put most styles and scripts into inline style and script tags was there, but because of the order of pattern matching, it was never being called. Putting the catch-all clause at the end fixes the bug. Closes #7635, closes #7367. See also #3423. --- src/Text/Pandoc/SelfContained.hs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/SelfContained.hs b/src/Text/Pandoc/SelfContained.hs index 3bbab4bbe..bd73c37dc 100644 --- a/src/Text/Pandoc/SelfContained.hs +++ b/src/Text/Pandoc/SelfContained.hs @@ -60,18 +60,6 @@ convertTags :: PandocMonad m => [Tag T.Text] -> m [Tag T.Text] convertTags [] = return [] convertTags (t@TagOpen{}:ts) | fromAttrib "data-external" t == "1" = (t:) <$> convertTags ts -convertTags (t@(TagOpen tagname as):ts) - | any (isSourceAttribute tagname) as - = do - as' <- mapM processAttribute as - rest <- convertTags ts - return $ TagOpen tagname as' : rest - where processAttribute (x,y) = - if isSourceAttribute tagname (x,y) - then do - enc <- getDataURI (fromAttrib "type" t) y - return (x, enc) - else return (x,y) convertTags (t@(TagOpen "script" as):TagClose "script":ts) = case fromAttrib "src" t of "" -> (t:) <$> convertTags ts @@ -125,6 +113,18 @@ convertTags (t@(TagOpen "link" as):ts) = return $ TagOpen "link" (("href",makeDataURI (mime, bs)) : [(x,y) | (x,y) <- as, x /= "href"]) : rest +convertTags (t@(TagOpen tagname as):ts) + | any (isSourceAttribute tagname) as + = do + as' <- mapM processAttribute as + rest <- convertTags ts + return $ TagOpen tagname as' : rest + where processAttribute (x,y) = + if isSourceAttribute tagname (x,y) + then do + enc <- getDataURI (fromAttrib "type" t) y + return (x, enc) + else return (x,y) convertTags (t:ts) = (t:) <$> convertTags ts cssURLs :: PandocMonad m -- cgit v1.2.3