git.iko.soy/typeable/pandoc
on master help sign in
EPUB writer: Removed need for separate epub-coverpage template.

The standard epub-page template is now used.

commita7b8351d436434165c6cc70ba855322c76c102cf authorJohn MacFarlane <fiddlosopher@gmail.com> dateSun 4 Nov 2012, 20:53 (14 years ago) parent7f5e2af
4 files changed+7−15
README+1−2 pandoc.cabal−1 src/Text/Pandoc/Writers/EPUB.hs+5−11 templates+1−1
README+1−2
@@ -661,8 +661,7 @@ by putting a file `templates/default.FORMAT` in the user data
661661directory (see `--data-dir`, above). *Exceptions:* For `odt` output,
662662customize the `default.opendocument` template. For `pdf` output,
663663customize the `default.latex` template. For `epub` and `epub3` output,
664−customize the `epub-page.html`, `epub-coverimage.html`, and
665−`epub-titlepage.html` templates.
664+customize the `epub-page.html`, and `epub-titlepage.html` templates.
666665
667666Templates may contain *variables*. Variable names are sequences of
668667alphanumerics, `-`, and `_`, starting with a letter. A variable name
pandoc.cabal−1
@@ -50,7 +50,6 @@ Data-Files:
5050 templates/default.dzslides, templates/default.asciidoc,
5151 templates/default.textile, templates/default.org,
5252 templates/epub-titlepage.html, templates/epub-page.html,
53− templates/epub-coverimage.html,
5453 -- data for ODT writer
5554 reference.odt,
5655 -- data for docx writer
src/Text/Pandoc/Writers/EPUB.hs+5−11
@@ -74,12 +74,15 @@ writeEPUB :: EPUBVersion
7474writeEPUB version opts doc@(Pandoc meta _) = do
7575 let epub3 = version == EPUB3
7676 epochtime <- floor `fmap` getPOSIXTime
77+ pageTemplate <- readDataFile (writerUserDataDir opts)
78+ $ "templates" </> "epub-page" <.> "html"
7779 let mkEntry path content = toEntry path epochtime content
7880 let vars = ("epub3", if epub3 then "true" else "false")
7981 : ("css", "stylesheet.css")
8082 : writerVariables opts
8183 let opts' = opts{ writerEmailObfuscation = NoObfuscation
8284 , writerStandalone = True
85+ , writerTemplate = pageTemplate
8386 , writerSectionDivs = True
8487 , writerHtml5 = epub3
8588 , writerTableOfContents = False -- we always have one in epub
@@ -95,23 +98,14 @@ writeEPUB version opts doc@(Pandoc meta _) = do
9598 titlePageTemplate <- readDataFile (writerUserDataDir opts')
9699 $ "templates" </> "epub-titlepage" <.> "html"
97100
98− coverImageTemplate <- readDataFile (writerUserDataDir opts')
99− $ "templates" </> "epub-coverimage" <.> "html"
100−
101− pageTemplate <- readDataFile (writerUserDataDir opts')
102− $ "templates" </> "epub-page" <.> "html"
103−
104101 -- cover page
105102 (cpgEntry, cpicEntry) <-
106103 case mbCoverImage of
107104 Nothing -> return ([],[])
108105 Just img -> do
109106 let coverImage = "cover-image" ++ takeExtension img
110− let cpContent = fromStringLazy $ writeHtmlString
111− opts'{writerTemplate = coverImageTemplate,
112− writerHtml5 = epub3,
113− writerVariables = ("coverimage",coverImage):vars}
114− (Pandoc meta [])
107+ let cpContent = renderHtml $ writeHtml opts'
108+ (Pandoc meta [RawBlock "html" $ "<div id=\"cover-image\">\n<img src=\"" ++ coverImage ++ " alt=\"cover image\" />\n</div"])
115109 imgContent <- B.readFile img
116110 return ( [mkEntry "cover.xhtml" cpContent]
117111 , [mkEntry coverImage imgContent] )
templates+1−1

Submodule changed.