git.iko.soy/typeable/pandoc
on master help sign in
EPUB writer: Take TOC title from toc-title metadata field.
b29a8a5John MacFarlane
src/Text/Pandoc/Writers/EPUB.hs+5−2
@@ -495,6 +495,9 @@ writeEPUB opts doc@(Pandoc meta _) = do
495 [] -> "UNTITLED"
495 [] -> "UNTITLED"
496 (x:_) -> titleText x
496 (x:_) -> titleText x
497 x -> stringify x
497 x -> stringify x
498+
499+ let tocTitle = fromMaybe plainTitle $
500+ metaValueToString <$> lookupMeta "toc-title" meta
498 let uuid = case epubIdentifier metadata of
501 let uuid = case epubIdentifier metadata of
499 (x:_) -> identifierText x -- use first identifier as UUID
502 (x:_) -> identifierText x -- use first identifier as UUID
500 [] -> error "epubIdentifier is null" -- shouldn't happen
503 [] -> error "epubIdentifier is null" -- shouldn't happen
@@ -539,7 +542,7 @@ writeEPUB opts doc@(Pandoc meta _) = do
539 map chapterRefNode chapterEntries)
542 map chapterRefNode chapterEntries)
540 , unode "guide" $
543 , unode "guide" $
541 [ unode "reference" !
544 [ unode "reference" !
542− [("type","toc"),("title",plainTitle),
545+ [("type","toc"),("title", tocTitle),
543 ("href","nav.xhtml")] $ ()
546 ("href","nav.xhtml")] $ ()
544 ] ++
547 ] ++
545 [ unode "reference" !
548 [ unode "reference" !
@@ -620,7 +623,7 @@ writeEPUB opts doc@(Pandoc meta _) = do
620 let navBlocks = [RawBlock (Format "html") $ ppElement $
623 let navBlocks = [RawBlock (Format "html") $ ppElement $
621 unode navtag ! ([("epub:type","toc") | epub3] ++
624 unode navtag ! ([("epub:type","toc") | epub3] ++
622 [("id","toc")]) $
625 [("id","toc")]) $
623− [ unode "h1" ! [("id","toc-title")] $ plainTitle
626+ [ unode "h1" ! [("id","toc-title")] $ tocTitle
624 , unode "ol" ! [("class","toc")] $ evalState (mapM (navPointNode navXhtmlFormatter) secs) 1]]
627 , unode "ol" ! [("class","toc")] $ evalState (mapM (navPointNode navXhtmlFormatter) secs) 1]]
625 let landmarks = if epub3
628 let landmarks = if epub3
626 then [RawBlock (Format "html") $ ppElement $
629 then [RawBlock (Format "html") $ ppElement $