git.iko.soy/typeable/pandoc
on master help sign in
EPUB writer: Removed need for separate epub-coverpage template.
a7b8351John MacFarlane
README+1−2
@@ -661,8 +661,7 @@ by putting a file `templates/default.FORMAT` in the user data
661directory (see `--data-dir`, above). *Exceptions:* For `odt` output,
661directory (see `--data-dir`, above). *Exceptions:* For `odt` output,
662customize the `default.opendocument` template. For `pdf` output,
662customize the `default.opendocument` template. For `pdf` output,
663customize the `default.latex` template. For `epub` and `epub3` output,
663customize 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.
666
665
667Templates may contain *variables*. Variable names are sequences of
666Templates may contain *variables*. Variable names are sequences of
668alphanumerics, `-`, and `_`, starting with a letter. A variable name
667alphanumerics, `-`, and `_`, starting with a letter. A variable name
pandoc.cabal−1
@@ -50,7 +50,6 @@ Data-Files:
50 templates/default.dzslides, templates/default.asciidoc,
50 templates/default.dzslides, templates/default.asciidoc,
51 templates/default.textile, templates/default.org,
51 templates/default.textile, templates/default.org,
52 templates/epub-titlepage.html, templates/epub-page.html,
52 templates/epub-titlepage.html, templates/epub-page.html,
53− templates/epub-coverimage.html,
54 -- data for ODT writer
53 -- data for ODT writer
55 reference.odt,
54 reference.odt,
56 -- data for docx writer
55 -- data for docx writer
src/Text/Pandoc/Writers/EPUB.hs+5−11
@@ -74,12 +74,15 @@ writeEPUB :: EPUBVersion
74writeEPUB version opts doc@(Pandoc meta _) = do
74writeEPUB version opts doc@(Pandoc meta _) = do
75 let epub3 = version == EPUB3
75 let epub3 = version == EPUB3
76 epochtime <- floor `fmap` getPOSIXTime
76 epochtime <- floor `fmap` getPOSIXTime
77+ pageTemplate <- readDataFile (writerUserDataDir opts)
78+ $ "templates" </> "epub-page" <.> "html"
77 let mkEntry path content = toEntry path epochtime content
79 let mkEntry path content = toEntry path epochtime content
78 let vars = ("epub3", if epub3 then "true" else "false")
80 let vars = ("epub3", if epub3 then "true" else "false")
79 : ("css", "stylesheet.css")
81 : ("css", "stylesheet.css")
80 : writerVariables opts
82 : writerVariables opts
81 let opts' = opts{ writerEmailObfuscation = NoObfuscation
83 let opts' = opts{ writerEmailObfuscation = NoObfuscation
82 , writerStandalone = True
84 , writerStandalone = True
85+ , writerTemplate = pageTemplate
83 , writerSectionDivs = True
86 , writerSectionDivs = True
84 , writerHtml5 = epub3
87 , writerHtml5 = epub3
85 , writerTableOfContents = False -- we always have one in epub
88 , writerTableOfContents = False -- we always have one in epub
@@ -95,23 +98,14 @@ writeEPUB version opts doc@(Pandoc meta _) = do
95 titlePageTemplate <- readDataFile (writerUserDataDir opts')
98 titlePageTemplate <- readDataFile (writerUserDataDir opts')
96 $ "templates" </> "epub-titlepage" <.> "html"
99 $ "templates" </> "epub-titlepage" <.> "html"
97
100
98− coverImageTemplate <- readDataFile (writerUserDataDir opts')
99− $ "templates" </> "epub-coverimage" <.> "html"
100−
101− pageTemplate <- readDataFile (writerUserDataDir opts')
102− $ "templates" </> "epub-page" <.> "html"
103−
104 -- cover page
101 -- cover page
105 (cpgEntry, cpicEntry) <-
102 (cpgEntry, cpicEntry) <-
106 case mbCoverImage of
103 case mbCoverImage of
107 Nothing -> return ([],[])
104 Nothing -> return ([],[])
108 Just img -> do
105 Just img -> do
109 let coverImage = "cover-image" ++ takeExtension img
106 let coverImage = "cover-image" ++ takeExtension img
110− let cpContent = fromStringLazy $ writeHtmlString
107+ let cpContent = renderHtml $ writeHtml opts'
111− opts'{writerTemplate = coverImageTemplate,
108+ (Pandoc meta [RawBlock "html" $ "<div id=\"cover-image\">\n<img src=\"" ++ coverImage ++ " alt=\"cover image\" />\n</div"])
112− writerHtml5 = epub3,
113− writerVariables = ("coverimage",coverImage):vars}
114− (Pandoc meta [])
115 imgContent <- B.readFile img
109 imgContent <- B.readFile img
116 return ( [mkEntry "cover.xhtml" cpContent]
110 return ( [mkEntry "cover.xhtml" cpContent]
117 , [mkEntry coverImage imgContent] )
111 , [mkEntry coverImage imgContent] )
templates+1−1

Submodule changed.