"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/Text/Pandoc/SelfContained.hs" between
pandoc-2.11.1.1.tar.gz and pandoc-2.11.2.tar.gz

About: Pandoc converts files from one markup format into another.

SelfContained.hs  (pandoc-2.11.1.1):SelfContained.hs  (pandoc-2.11.2)
skipping to change at line 53 skipping to change at line 53
makeDataURI :: (MimeType, ByteString) -> T.Text makeDataURI :: (MimeType, ByteString) -> T.Text
makeDataURI (mime, raw) = makeDataURI (mime, raw) =
if textual if textual
then "data:" <> mime' <> "," <> T.pack (escapeURIString isOk (toString raw) ) then "data:" <> mime' <> "," <> T.pack (escapeURIString isOk (toString raw) )
else "data:" <> mime' <> ";base64," <> toText (encode raw) else "data:" <> mime' <> ";base64," <> toText (encode raw)
where textual = "text/" `T.isPrefixOf` mime where textual = "text/" `T.isPrefixOf` mime
mime' = if textual && T.any (== ';') mime mime' = if textual && T.any (== ';') mime
then mime <> ";charset=utf-8" then mime <> ";charset=utf-8"
else mime -- mime type already has charset else mime -- mime type already has charset
isSourceAttribute :: T.Text -> (T.Text, T.Text) -> Bool
isSourceAttribute tagname (x,_) =
x == "src" ||
x == "data-src" ||
(x == "href" && tagname == "link") ||
x == "poster" ||
x == "data-background-image"
convertTags :: PandocMonad m => [Tag T.Text] -> m [Tag T.Text] convertTags :: PandocMonad m => [Tag T.Text] -> m [Tag T.Text]
convertTags [] = return [] convertTags [] = return []
convertTags (t@TagOpen{}:ts) convertTags (t@TagOpen{}:ts)
| fromAttrib "data-external" t == "1" = (t:) <$> convertTags ts | fromAttrib "data-external" t == "1" = (t:) <$> convertTags ts
convertTags (t@(TagOpen tagname as):ts) convertTags (t@(TagOpen tagname as):ts)
| tagname `elem` | any (isSourceAttribute tagname) as
["img", "embed", "video", "input", "audio", "source", "track", = do
"section"] = do
as' <- mapM processAttribute as as' <- mapM processAttribute as
rest <- convertTags ts rest <- convertTags ts
return $ TagOpen tagname as' : rest return $ TagOpen tagname as' : rest
where processAttribute (x,y) = where processAttribute (x,y) =
if x `elem` ["src", "data-src", "href", "poster", "data-background-im age"] if isSourceAttribute tagname (x,y)
then do then do
enc <- getDataURI (fromAttrib "type" t) y enc <- getDataURI (fromAttrib "type" t) y
return (x, enc) return (x, enc)
else return (x,y) else return (x,y)
convertTags (t@(TagOpen "script" as):TagClose "script":ts) = convertTags (t@(TagOpen "script" as):TagClose "script":ts) =
case fromAttrib "src" t of case fromAttrib "src" t of
"" -> (t:) <$> convertTags ts "" -> (t:) <$> convertTags ts
src -> do src -> do
let typeAttr = fromAttrib "type" t let typeAttr = fromAttrib "type" t
res <- getData typeAttr src res <- getData typeAttr src
 End of changes. 3 change blocks. 
4 lines changed or deleted 11 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)