From 2d1968dd0b2a24cc6ff61cba2d86ebb0fc86d7df Mon Sep 17 00:00:00 2001 From: Mario Botsch Date: Fri, 20 Oct 2017 16:52:44 +0200 Subject: [PATCH] Demos: prevent iframe content from being scrollable, replaced src by data-src to allow for reveal's lazy loading Meshes: added filter to include 3D mesh viewer --- src/Text/Pandoc/Util/Filter/Media.hs | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/Text/Pandoc/Util/Filter/Media.hs b/src/Text/Pandoc/Util/Filter/Media.hs index 61ff7c6..05340fa 100644 --- a/src/Text/Pandoc/Util/Filter/Media.hs +++ b/src/Text/Pandoc/Util/Filter/Media.hs @@ -44,6 +44,11 @@ imgExt = demoExt :: [String] demoExt = ["html", "htm"] +-- | File-extensions that should be treated as 3D model and will be shown with Mario's viewer +-- in an iframe +meshExt :: [String] +meshExt = ["off", "obj", "stl"] + -- | main media-plugin. -- -- Will convert the following syntax @@ -134,16 +139,31 @@ media (Image (id', att, att') alt (filename,_)) where (direct, css) = (classToRevealAttr . revealjsRewriteAttr) att style = filterStyle att' ---html-demos etc. as IFrames +--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 + = return [toHtml $ ""] + where + (direct, css) = (classToRevealAttr . revealjsRewriteAttr) att +media (Image (id', att, att') alt (filename,_)) + | checkExtension filename meshExt + = return $ [toHtml $ "
attToString (id', css, att') <> ">"] + <> [toHtml $ ""] <> [toHtml $ "
"] <> alt <> [toHtml $ "
"]