summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers/EPUB.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2012-11-02 20:53:51 -0700
committerJohn MacFarlane <fiddlosopher@gmail.com>2012-11-02 20:53:51 -0700
commit927a9271a5b0d20fac9f869fbf19426e521c9be9 (patch)
tree0485a15daa8c19f902ea62134e1f84d1b767b4bc /src/Text/Pandoc/Writers/EPUB.hs
parent583ce1073c8a3b1b52558d703a0e8fbb071269a4 (diff)
EPUB: Set epub3 template variable controlling doctype.
Diffstat (limited to 'src/Text/Pandoc/Writers/EPUB.hs')
-rw-r--r--src/Text/Pandoc/Writers/EPUB.hs8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs
index 63a17f608..5d557824f 100644
--- a/src/Text/Pandoc/Writers/EPUB.hs
+++ b/src/Text/Pandoc/Writers/EPUB.hs
@@ -72,13 +72,14 @@ writeEPUB :: EPUBVersion
-> Pandoc -- ^ Document to convert
-> IO B.ByteString
writeEPUB version opts doc@(Pandoc meta _) = do
+ let epub3 = version == EPUB3
epochtime <- floor `fmap` getPOSIXTime
let mkEntry path content = toEntry path epochtime content
let opts' = opts{ writerEmailObfuscation = NoObfuscation
, writerStandalone = True
, writerWrapText = False }
let sourceDir = writerSourceDirectory opts'
- let vars = writerVariables opts'
+ let vars = ("epub3", if epub3 then "true" else "false"):writerVariables opts'
let mbCoverImage = lookup "epub-cover-image" vars
titlePageTemplate <- readDataFile (writerUserDataDir opts)
@@ -106,7 +107,8 @@ writeEPUB version opts doc@(Pandoc meta _) = do
-- title page
let tpContent = fromStringLazy $ writeHtmlString
- opts'{writerTemplate = titlePageTemplate}
+ opts'{writerTemplate = titlePageTemplate,
+ writerVariables = vars}
(Pandoc meta [])
let tpEntry = mkEntry "title_page.xhtml" tpContent
@@ -140,7 +142,7 @@ writeEPUB version opts doc@(Pandoc meta _) = do
let chapToEntry :: Int -> [Tag String] -> Entry
chapToEntry num ts = mkEntry (showChapter num)
$ fromStringLazy
- $ renderTemplate [("body",renderTags ts), ("pagetitle",show num)]
+ $ renderTemplate (("body",renderTags ts):("pagetitle",show num):vars)
$ pageTemplate
let chapterEntries = zipWith chapToEntry [1..] chunks