From 5c7bfe8ac9dcbc899dd13052e259f44ecf03d7c4 Mon Sep 17 00:00:00 2001 From: Mario Botsch Date: Mon, 26 Feb 2018 23:15:41 +0100 Subject: [PATCH] add php to demo extensions; remove figure from img/video without caption; remove no-scrolling from iframe --- src/Text/Pandoc/Util/Filter/Media.hs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/Text/Pandoc/Util/Filter/Media.hs b/src/Text/Pandoc/Util/Filter/Media.hs index d70845f..b7c95fa 100644 --- a/src/Text/Pandoc/Util/Filter/Media.hs +++ b/src/Text/Pandoc/Util/Filter/Media.hs @@ -42,7 +42,7 @@ imgExt = -- | File-extensions that should be treated as demo and will be included -- in an iframe demoExt :: [String] -demoExt = ["html", "htm"] +demoExt = ["html", "htm", "php"] -- | File-extensions that should be treated as 3D model and will be shown with Mario's viewer -- in an iframe @@ -67,6 +67,8 @@ meshExt = ["off", "obj", "stl"] -- will be preserved. -- media :: Inline -> IO [Inline] + + --audio media (Image (id',att,att') [] (filename,_)) | id' == "audio" || checkExtension filename audioExt @@ -81,6 +83,8 @@ media (Image (id',att,att') alt (filename,_)) <> [toHtml $ ""] where (direct, css) = (classToRevealAttr . revealjsRewriteAttr) att + + --videos media (Image (id', att, att') [] (filename,_)) | id' == "video" || checkExtension filename videoExt @@ -97,6 +101,8 @@ media (Image (id', att, att') alt (filename,_)) where (direct, css) = (classToRevealAttr . revealjsRewriteAttr) att style = filterStyle att' + + --load svg and dump it in media (Image (id', att, att') [] (filename,_)) | id' == "svg" @@ -120,12 +126,12 @@ media (Image (id', att, att') alt (filename,_)) <> [toHtml $ ""] where (direct, css) = (classToRevealAttr . revealjsRewriteAttr) att + + --images media (Image (id', att, att') [] (filename,_)) | id' == "img" || checkExtension filename imgExt - = return $ [toHtml $ "
attToString (idFilter "img" id',css,att') <> ">"] - <> [toHtml $ " unwords direct <> " src=\"" <> filename <> "\" style=\"" <> style <> "\">"] - <> [toHtml $ "
"] + = return $ [toHtml $ " unwords direct <> " src=\"" <> filename <> "\" style=\"" <> style <> "\">"] where (direct, css) = (classToRevealAttr . revealjsRewriteAttr) att style = filterStyle att' @@ -144,13 +150,13 @@ media (Image (id', att, att') alt (filename,_)) --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 $ "
"] @@ -179,6 +185,7 @@ media (Image (id', att, att') alt (filename,_)) -- 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 . takeWhile (/='?')) fn `elem` exts