diff options
author | John MacFarlane <jgm@berkeley.edu> | 2021-10-21 21:51:53 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2021-10-21 21:51:53 -0700 |
commit | ef7b769fa07e2cbf4e9b8004484828628f548409 (patch) | |
tree | 48302448afb000bf37c3ce8c742fde5fb4262525 /src | |
parent | fcd3384f9f058cf199f4fd10a25b6c700fd12a44 (diff) | |
download | pandoc-ef7b769fa07e2cbf4e9b8004484828628f548409.tar.gz |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/SelfContained.hs | 24 |
1 files changed, 12 insertions, 12 deletions
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 |