aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2011-07-24 11:36:54 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2011-07-24 11:36:54 -0700
commit7b4c1b171c1d7bb542b464160e010a2118ed0fe5 (patch)
tree9b00f29743922a3bca0c8c4e492c7c98c56a3695
parentd6df566a75ea839a60247a5e028408ea2f1841db (diff)
downloadpandoc-7b4c1b171c1d7bb542b464160e010a2118ed0fe5.tar.gz
Use data: protocol to embed s5 css in <link> tags.
Using inline css didn't work properly with Chrome and Safari.
-rw-r--r--pandoc.cabal6
-rw-r--r--src/Text/Pandoc/S5.hs27
2 files changed, 20 insertions, 13 deletions
diff --git a/pandoc.cabal b/pandoc.cabal
index d891185c8..20b4518e8 100644
--- a/pandoc.cabal
+++ b/pandoc.cabal
@@ -210,7 +210,8 @@ Library
pandoc-types == 1.8.*,
json >= 0.4 && < 0.5,
dlist >= 0.4 && < 0.6,
- tagsoup >= 0.12 && < 0.13
+ tagsoup >= 0.12 && < 0.13,
+ base64-bytestring >= 0.1 && < 0.2
if impl(ghc >= 6.10)
Build-depends: base >= 4 && < 5, syb >= 0.1 && < 0.4
else
@@ -295,7 +296,8 @@ Executable pandoc
pandoc-types == 1.8.*,
json >= 0.4 && < 0.5,
dlist >= 0.4 && < 0.6,
- tagsoup >= 0.12 && < 0.13
+ tagsoup >= 0.12 && < 0.13,
+ base64-bytestring >= 0.1 && < 0.2
if impl(ghc >= 6.10)
Build-depends: base >= 4 && < 5, syb >= 0.1 && < 0.4
else
diff --git a/src/Text/Pandoc/S5.hs b/src/Text/Pandoc/S5.hs
index 5658433ae..b17b052c5 100644
--- a/src/Text/Pandoc/S5.hs
+++ b/src/Text/Pandoc/S5.hs
@@ -31,6 +31,8 @@ Definitions for creation of S5 powerpoint-like HTML.
module Text.Pandoc.S5 ( s5HeaderIncludes) where
import Text.Pandoc.Shared ( readDataFile )
import System.FilePath ( (</>) )
+import Data.ByteString.UTF8 ( toString, fromString )
+import Data.ByteString.Base64 ( encode )
s5HeaderIncludes :: Maybe FilePath -> IO String
s5HeaderIncludes datadir = do
@@ -38,14 +40,17 @@ s5HeaderIncludes datadir = do
j <- s5Javascript datadir
return $ c ++ j
-inCDATA :: String -> String
-inCDATA s = "/*<![CDATA[*/\n" ++ s ++ "\n/*]]>*/\n"
-
s5Javascript :: Maybe FilePath -> IO String
s5Javascript datadir = do
js <- readDataFile datadir $ "s5" </> "default" </> "slides.min.js"
return $ "<script type=\"text/javascript\">\n" ++ inCDATA js ++ "</script>\n"
+inCDATA :: String -> String
+inCDATA s = "/*<![CDATA[*/\n" ++ s ++ "\n/*]]>*/\n"
+
+base64 :: String -> String
+base64 = toString . encode . fromString
+
s5CSS :: Maybe FilePath -> IO String
s5CSS datadir = do
s5CoreCSS <- readDataFile datadir $ "s5" </> "default" </> "s5-core.css"
@@ -54,11 +59,11 @@ s5CSS datadir = do
s5OperaCSS <- readDataFile datadir $ "s5" </> "default" </> "opera.css"
s5OutlineCSS <- readDataFile datadir $ "s5" </> "default" </> "outline.css"
s5PrintCSS <- readDataFile datadir $ "s5" </> "default" </> "print.css"
- return $ "<style type=\"text/css\" media=\"projection\" id=\"slideProj\">\n" ++
- inCDATA (s5CoreCSS ++ "\n" ++ s5FramingCSS ++ "\n" ++ s5PrettyCSS) ++
- "</style>\n<style type=\"text/css\" media=\"screen\" id=\"outlineStyle\">\n" ++
- inCDATA s5OutlineCSS ++
- "</style>\n<style type=\"text/css\" media=\"print\" id=\"slidePrint\">\n" ++
- inCDATA s5PrintCSS ++
- "</style>\n<style type=\"text/css\" media=\"projection\" id=\"operaFix\">\n" ++
- inCDATA s5OperaCSS ++ "</style>\n"
+ return $ "<link rel=\"stylesheet\" type=\"text/css\" media=\"projection\" id=\"slideProj\" href=\"data:text/css;charset=utf-8;base64," ++
+ base64 (s5CoreCSS ++ "\n" ++ s5FramingCSS ++ "\n" ++ s5PrettyCSS) ++ "\" />\n" ++
+ "<link rel=\"stylesheet\" type=\"text/css\" media=\"screen\" id=\"outlineStyle\" href=\"data:text/css;charset=utf-8;base64," ++
+ base64 s5OutlineCSS ++ "\" />\n" ++
+ "<link rel=\"stylesheet\" type=\"text/css\" media=\"print\" id=\"slidePrint\" href=\"data:text/css;charset=utf-8;base64," ++
+ base64 s5PrintCSS ++ "\" />\n" ++
+ "<link rel=\"stylesheet\" type=\"text/css\" media=\"projection\" id=\"operaFix\" href=\"data:text/css;charset=utf-8;base64," ++
+ base64 s5OperaCSS ++ "\" />\n"