git.iko.soy/typeable/pandoc
on master help sign in
EPUB writer: Rationalized templates.

* Previously there were three different templates involved in epub production. There is now just one template, default.epub or default.epub3. * It can now be overridden using `--template`, just like other templates.

commit5914be88a8e783cb8368e654109dc291a6d92092 authorJohn MacFarlane <fiddlosopher@gmail.com> dateSun 4 Nov 2012, 21:21 (14 years ago) parent83b326b
5 files changed+6−14
README+1−2 pandoc.cabal+1−1 src/Text/Pandoc/Templates.hs−2 src/Text/Pandoc/Writers/EPUB.hs+3−8 templates+1−1
README+1−2
@@ -660,8 +660,7 @@ the system default templates for a given output format `FORMAT`
660660by 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,
663−customize the `default.latex` template. For `epub` and `epub3` output,
664−customize the `epub-page.html` template.
663+customize the `default.latex` template.
665664
666665Templates may contain *variables*. Variable names are sequences of
667666alphanumerics, `-`, and `_`, starting with a letter. A variable name
pandoc.cabal+1−1
@@ -49,7 +49,7 @@ Data-Files:
4949 templates/default.slideous,
5050 templates/default.dzslides, templates/default.asciidoc,
5151 templates/default.textile, templates/default.org,
52− templates/epub-page.html,
52+ templates/default.epub, templates/default.epub3,
5353 -- data for ODT writer
5454 reference.odt,
5555 -- data for docx writer
src/Text/Pandoc/Templates.hs−2
@@ -93,8 +93,6 @@ getDefaultTemplate user writer = do
9393 "native" -> return $ Right ""
9494 "json" -> return $ Right ""
9595 "docx" -> return $ Right ""
96− "epub" -> return $ Right ""
97− "epub3" -> return $ Right ""
9896 "odt" -> getDefaultTemplate user "opendocument"
9997 "markdown_strict" -> getDefaultTemplate user "markdown"
10098 "multimarkdown" -> getDefaultTemplate user "markdown"
src/Text/Pandoc/Writers/EPUB.hs+3−8
@@ -33,7 +33,7 @@ import Data.Maybe ( fromMaybe, isNothing )
3333import Data.List ( isPrefixOf, isInfixOf, intercalate )
3434import System.Environment ( getEnv )
3535import Text.Printf (printf)
36−import System.FilePath ( (</>), (<.>), takeBaseName, takeExtension, takeFileName )
36+import System.FilePath ( (</>), takeBaseName, takeExtension, takeFileName )
3737import qualified Data.ByteString.Lazy as B
3838import qualified Data.ByteString.Lazy.Char8 as B8
3939import Text.Pandoc.UTF8 ( fromStringLazy )
@@ -74,15 +74,12 @@ 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"
7977 let mkEntry path content = toEntry path epochtime content
8078 let vars = ("epub3", if epub3 then "true" else "false")
8179 : ("css", "stylesheet.css")
8280 : writerVariables opts
8381 let opts' = opts{ writerEmailObfuscation = NoObfuscation
8482 , writerStandalone = True
85− , writerTemplate = pageTemplate
8683 , writerSectionDivs = True
8784 , writerHtml5 = epub3
8885 , writerTableOfContents = False -- we always have one in epub
@@ -102,7 +99,7 @@ writeEPUB version opts doc@(Pandoc meta _) = do
10299 Just img -> do
103100 let coverImage = "cover-image" ++ takeExtension img
104101 let cpContent = renderHtml $ writeHtml opts'
105− (Pandoc meta [RawBlock "html" $ "<div id=\"cover-image\">\n<img src=\"" ++ coverImage ++ " alt=\"cover image\" />\n</div"])
102+ (Pandoc meta [RawBlock "html" $ "<div id=\"cover-image\">\n<img src=\"" ++ coverImage ++ "\" alt=\"cover image\" />\n</div>"])
106103 imgContent <- B.readFile img
107104 return ( [mkEntry "cover.xhtml" cpContent]
108105 , [mkEntry coverImage imgContent] )
@@ -149,9 +146,7 @@ writeEPUB version opts doc@(Pandoc meta _) = do
149146 let chapToEntry :: Int -> [Block] -> Entry
150147 chapToEntry num bs = mkEntry (showChapter num)
151148 $ renderHtml
152− $ writeHtml opts'{ writerStandalone = True
153− , writerTemplate = pageTemplate
154− }
149+ $ writeHtml opts'
155150 $ case bs of
156151 (Header 1 xs : _) -> Pandoc (Meta xs [] []) bs
157152 _ -> Pandoc (Meta [] [] []) bs
templates+1−1

Submodule changed.