git.iko.soy/typeable/pandoc
on master help sign in
Use data: protocol to embed s5 css in <link> tags.

Using inline css didn't work properly with Chrome and Safari.

commit7b4c1b171c1d7bb542b464160e010a2118ed0fe5 authorJohn MacFarlane <jgm@berkeley.edu> dateSun 24 Jul 2011, 11:36 (15 years ago) parentd6df566
2 files changed+20−13
pandoc.cabal+4−2 src/Text/Pandoc/S5.hs+16−11
pandoc.cabal+4−2
@@ -210,7 +210,8 @@ Library
210210 pandoc-types == 1.8.*,
211211 json >= 0.4 && < 0.5,
212212 dlist >= 0.4 && < 0.6,
213− tagsoup >= 0.12 && < 0.13
213+ tagsoup >= 0.12 && < 0.13,
214+ base64-bytestring >= 0.1 && < 0.2
214215 if impl(ghc >= 6.10)
215216 Build-depends: base >= 4 && < 5, syb >= 0.1 && < 0.4
216217 else
@@ -295,7 +296,8 @@ Executable pandoc
295296 pandoc-types == 1.8.*,
296297 json >= 0.4 && < 0.5,
297298 dlist >= 0.4 && < 0.6,
298− tagsoup >= 0.12 && < 0.13
299+ tagsoup >= 0.12 && < 0.13,
300+ base64-bytestring >= 0.1 && < 0.2
299301 if impl(ghc >= 6.10)
300302 Build-depends: base >= 4 && < 5, syb >= 0.1 && < 0.4
301303 else
src/Text/Pandoc/S5.hs+16−11
@@ -31,6 +31,8 @@ Definitions for creation of S5 powerpoint-like HTML.
3131module Text.Pandoc.S5 ( s5HeaderIncludes) where
3232import Text.Pandoc.Shared ( readDataFile )
3333import System.FilePath ( (</>) )
34+import Data.ByteString.UTF8 ( toString, fromString )
35+import Data.ByteString.Base64 ( encode )
3436
3537s5HeaderIncludes :: Maybe FilePath -> IO String
3638s5HeaderIncludes datadir = do
@@ -38,14 +40,17 @@ s5HeaderIncludes datadir = do
3840 j <- s5Javascript datadir
3941 return $ c ++ j
4042
41−inCDATA :: String -> String
42−inCDATA s = "/*<![CDATA[*/\n" ++ s ++ "\n/*]]>*/\n"
43−
4443s5Javascript :: Maybe FilePath -> IO String
4544s5Javascript datadir = do
4645 js <- readDataFile datadir $ "s5" </> "default" </> "slides.min.js"
4746 return $ "<script type=\"text/javascript\">\n" ++ inCDATA js ++ "</script>\n"
4847
48+inCDATA :: String -> String
49+inCDATA s = "/*<![CDATA[*/\n" ++ s ++ "\n/*]]>*/\n"
50+
51+base64 :: String -> String
52+base64 = toString . encode . fromString
53+
4954s5CSS :: Maybe FilePath -> IO String
5055s5CSS datadir = do
5156 s5CoreCSS <- readDataFile datadir $ "s5" </> "default" </> "s5-core.css"
@@ -54,11 +59,11 @@ s5CSS datadir = do
5459 s5OperaCSS <- readDataFile datadir $ "s5" </> "default" </> "opera.css"
5560 s5OutlineCSS <- readDataFile datadir $ "s5" </> "default" </> "outline.css"
5661 s5PrintCSS <- readDataFile datadir $ "s5" </> "default" </> "print.css"
57− return $ "<style type=\"text/css\" media=\"projection\" id=\"slideProj\">\n" ++
58− inCDATA (s5CoreCSS ++ "\n" ++ s5FramingCSS ++ "\n" ++ s5PrettyCSS) ++
59− "</style>\n<style type=\"text/css\" media=\"screen\" id=\"outlineStyle\">\n" ++
60− inCDATA s5OutlineCSS ++
61− "</style>\n<style type=\"text/css\" media=\"print\" id=\"slidePrint\">\n" ++
62− inCDATA s5PrintCSS ++
63− "</style>\n<style type=\"text/css\" media=\"projection\" id=\"operaFix\">\n" ++
64− inCDATA s5OperaCSS ++ "</style>\n"
62+ return $ "<link rel=\"stylesheet\" type=\"text/css\" media=\"projection\" id=\"slideProj\" href=\"data:text/css;charset=utf-8;base64," ++
63+ base64 (s5CoreCSS ++ "\n" ++ s5FramingCSS ++ "\n" ++ s5PrettyCSS) ++ "\" />\n" ++
64+ "<link rel=\"stylesheet\" type=\"text/css\" media=\"screen\" id=\"outlineStyle\" href=\"data:text/css;charset=utf-8;base64," ++
65+ base64 s5OutlineCSS ++ "\" />\n" ++
66+ "<link rel=\"stylesheet\" type=\"text/css\" media=\"print\" id=\"slidePrint\" href=\"data:text/css;charset=utf-8;base64," ++
67+ base64 s5PrintCSS ++ "\" />\n" ++
68+ "<link rel=\"stylesheet\" type=\"text/css\" media=\"projection\" id=\"operaFix\" href=\"data:text/css;charset=utf-8;base64," ++
69+ base64 s5OperaCSS ++ "\" />\n"