From 4e6c9cf6d03c1105f5c17038504b9e368da48392 Mon Sep 17 00:00:00 2001 From: Mario Botsch Date: Sun, 22 Oct 2017 13:38:13 +0200 Subject: [PATCH] Media.hs: removed "?plugin" extension from HTML URLs modified checkExtension to ignore options in URLs --- src/Text/Pandoc/Util/Filter/Media.hs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Text/Pandoc/Util/Filter/Media.hs b/src/Text/Pandoc/Util/Filter/Media.hs index 05340fa..d70845f 100644 --- a/src/Text/Pandoc/Util/Filter/Media.hs +++ b/src/Text/Pandoc/Util/Filter/Media.hs @@ -139,21 +139,25 @@ media (Image (id', att, att') alt (filename,_)) where (direct, css) = (classToRevealAttr . revealjsRewriteAttr) att style = filterStyle att' + + --html-demos etc. as IFrames (use data-src instead of src to enable lazy-loading) media (Image (id', att, att') [] (filename,_)) | id' == "demo" || checkExtension filename demoExt - = return [toHtml $ ""] + = return [toHtml $ ""] where (direct, css) = (classToRevealAttr . revealjsRewriteAttr) att media (Image (id', att, att') alt (filename,_)) | id' == "demo" || checkExtension filename demoExt = return $ [toHtml $ "
attToString (idFilter "demo" id', css, att') <> ">"] - <> [toHtml $ ""] + <> [toHtml $ ""] <> [toHtml $ "
"] <> alt <> [toHtml $ "
"] where (direct, css) = (classToRevealAttr . revealjsRewriteAttr) att + + --3D meshes shown in a WebGL viewer in an iframe (use data-src to enable reveal's lazy loading) media (Image (id', att, att') [] (filename,_)) | checkExtension filename meshExt @@ -169,11 +173,16 @@ media (Image (id', att, att') alt (filename,_)) <> [toHtml $ ""] where (direct, css) = (classToRevealAttr . revealjsRewriteAttr) att + + + -- if not matched media x = return [x] +-- return filename extension (strip additional arguments from HTML URLs) checkExtension :: String -> [String] -> Bool -checkExtension fn exts = (fmap toLower . tail . takeExtension) fn `elem` exts +checkExtension fn exts = (fmap toLower . tail . takeExtension . takeWhile (/='?')) fn `elem` exts +-- checkExtension fn exts = (fmap toLower . tail . takeExtension) fn `elem` exts idFilter :: String -> String -> String idFilter a b