aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/SelfContained.hs18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/Text/Pandoc/SelfContained.hs b/src/Text/Pandoc/SelfContained.hs
index 6112e764f..7fc9c2966 100644
--- a/src/Text/Pandoc/SelfContained.hs
+++ b/src/Text/Pandoc/SelfContained.hs
@@ -50,14 +50,16 @@ isOk c = isAscii c && isAlphaNum c
convertTag :: Maybe FilePath -> Tag String -> IO (Tag String)
convertTag userdata t@(TagOpen tagname as)
- | tagname `elem` ["img", "embed", "video", "input", "audio", "source"] =
- case fromAttrib "src" t of
- [] -> return t
- src -> do
- (raw, mime) <- getRaw userdata (fromAttrib "type" t) src
- let enc = "data:" ++ mime ++ ";base64," ++ toString (encode raw)
- return $ TagOpen tagname
- (("src",enc) : [(x,y) | (x,y) <- as, x /= "src"])
+ | tagname `elem` ["img", "embed", "video", "input", "audio", "source"] = do
+ as' <- mapM processAttribute as
+ return $ TagOpen tagname as'
+ where processAttribute (x,y) =
+ if x == "src" || x == "href" || x == "poster"
+ then do
+ (raw, mime) <- getRaw userdata (fromAttrib "type" t) y
+ let enc = "data:" ++ mime ++ ";base64," ++ toString (encode raw)
+ return (x, enc)
+ else return (x,y)
convertTag userdata t@(TagOpen "script" as) =
case fromAttrib "src" t of
[] -> return t