diff options
Diffstat (limited to 'src/Text/Pandoc/Writers')
-rw-r--r-- | src/Text/Pandoc/Writers/EPUB.hs | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs index 8d0a46949..f1ff8b482 100644 --- a/src/Text/Pandoc/Writers/EPUB.hs +++ b/src/Text/Pandoc/Writers/EPUB.hs @@ -403,6 +403,12 @@ pandocToEPUB version opts doc@(Pandoc meta _) = do writeHtmlStringForEPUB version o metadata <- getEPUBMetadata opts meta + let plainTitle = case docTitle' meta of + [] -> case epubTitle metadata of + [] -> "UNTITLED" + (x:_) -> titleText x + x -> stringify x + -- stylesheet stylesheets <- case epubStylesheets metadata of [] -> (\x -> [B.fromChunks [x]]) <$> @@ -440,6 +446,7 @@ pandocToEPUB version opts doc@(Pandoc meta _) = do cpContent <- lift $ writeHtml opts'{ writerVariables = ("coverpage","true"): + ("pagetitle",plainTitle): cssvars True ++ vars } (Pandoc meta [RawBlock (Format "html") $ "<div id=\"cover-image\">\n<img src=\"../media/" ++ coverImage ++ "\" alt=\"cover image\" />\n</div>"]) imgContent <- lift $ P.readFileLazy img @@ -452,6 +459,7 @@ pandocToEPUB version opts doc@(Pandoc meta _) = do -- title page tpContent <- lift $ writeHtml opts'{ writerVariables = ("titlepage","true"): + ("pagetitle",plainTitle): cssvars True ++ vars } (Pandoc meta []) tpEntry <- mkEntry "text/title_page.xhtml" tpContent @@ -604,11 +612,6 @@ pandocToEPUB version opts doc@(Pandoc meta _) = do $ eRelativePath ent), ("media-type", fromMaybe "" $ getMimeType $ eRelativePath ent)] $ () - let plainTitle = case docTitle' meta of - [] -> case epubTitle metadata of - [] -> "UNTITLED" - (x:_) -> titleText x - x -> stringify x let tocTitle = fromMaybe plainTitle $ metaValueToString <$> lookupMeta "toc-title" meta @@ -749,7 +752,10 @@ pandocToEPUB version opts doc@(Pandoc meta _) = do where titElements = parseXML titRendered titRendered = case P.runPure (writeHtmlStringForEPUB version - opts{ writerTemplate = Nothing } + opts{ writerTemplate = Nothing + , writerVariables = + ("pagetitle",plainTitle): + writerVariables opts} (Pandoc nullMeta [Plain $ walk clean tit])) of Left _ -> TS.pack $ stringify tit |