mirror of
https://github.com/jgm/pandoc.git
synced 2026-09-23 07:55:45 +00:00
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.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user