diff options
-rw-r--r-- | README | 3 | ||||
-rw-r--r-- | pandoc.cabal | 1 | ||||
-rw-r--r-- | src/Text/Pandoc/Writers/EPUB.hs | 16 | ||||
m--------- | templates | 13 |
4 files changed, 12 insertions, 21 deletions
@@ -661,8 +661,7 @@ by putting a file `templates/default.FORMAT` in the user data directory (see `--data-dir`, above). *Exceptions:* For `odt` output, customize the `default.opendocument` template. For `pdf` output, customize the `default.latex` template. For `epub` and `epub3` output, -customize the `epub-page.html`, `epub-coverimage.html`, and -`epub-titlepage.html` templates. +customize the `epub-page.html`, and `epub-titlepage.html` templates. Templates may contain *variables*. Variable names are sequences of alphanumerics, `-`, and `_`, starting with a letter. A variable name diff --git a/pandoc.cabal b/pandoc.cabal index 356b38b33..279b327b9 100644 --- a/pandoc.cabal +++ b/pandoc.cabal @@ -50,7 +50,6 @@ Data-Files: templates/default.dzslides, templates/default.asciidoc, templates/default.textile, templates/default.org, templates/epub-titlepage.html, templates/epub-page.html, - templates/epub-coverimage.html, -- data for ODT writer reference.odt, -- data for docx writer diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs index 4effc7b2b..dabb9722b 100644 --- a/src/Text/Pandoc/Writers/EPUB.hs +++ b/src/Text/Pandoc/Writers/EPUB.hs @@ -74,12 +74,15 @@ writeEPUB :: EPUBVersion writeEPUB version opts doc@(Pandoc meta _) = do let epub3 = version == EPUB3 epochtime <- floor `fmap` getPOSIXTime + pageTemplate <- readDataFile (writerUserDataDir opts) + $ "templates" </> "epub-page" <.> "html" let mkEntry path content = toEntry path epochtime content let vars = ("epub3", if epub3 then "true" else "false") : ("css", "stylesheet.css") : writerVariables opts let opts' = opts{ writerEmailObfuscation = NoObfuscation , writerStandalone = True + , writerTemplate = pageTemplate , writerSectionDivs = True , writerHtml5 = epub3 , writerTableOfContents = False -- we always have one in epub @@ -95,23 +98,14 @@ writeEPUB version opts doc@(Pandoc meta _) = do titlePageTemplate <- readDataFile (writerUserDataDir opts') $ "templates" </> "epub-titlepage" <.> "html" - coverImageTemplate <- readDataFile (writerUserDataDir opts') - $ "templates" </> "epub-coverimage" <.> "html" - - pageTemplate <- readDataFile (writerUserDataDir opts') - $ "templates" </> "epub-page" <.> "html" - -- cover page (cpgEntry, cpicEntry) <- case mbCoverImage of Nothing -> return ([],[]) Just img -> do let coverImage = "cover-image" ++ takeExtension img - let cpContent = fromStringLazy $ writeHtmlString - opts'{writerTemplate = coverImageTemplate, - writerHtml5 = epub3, - writerVariables = ("coverimage",coverImage):vars} - (Pandoc meta []) + let cpContent = renderHtml $ writeHtml opts' + (Pandoc meta [RawBlock "html" $ "<div id=\"cover-image\">\n<img src=\"" ++ coverImage ++ " alt=\"cover image\" />\n</div"]) imgContent <- B.readFile img return ( [mkEntry "cover.xhtml" cpContent] , [mkEntry coverImage imgContent] ) diff --git a/templates b/templates -Subproject 9fae8b31dd1fc3667993a35b7db6b252b85c840 +Subproject cd898b1d2febb88686054e4a63690b8c7891ae0 |