@@ -406,7 +406,7 @@ writeEPUB opts doc@(Pandoc meta _) = do
406 $ case blocks of
406 $ case blocks of
407 (Header 1 _ _ : _) -> blocks
407 (Header 1 _ _ : _) -> blocks
408 _ -> Header 1 ("",["unnumbered"],[])
408 _ -> Header 1 ("",["unnumbered"],[])
409− (docTitle meta) : blocks
409+ (docTitle' meta) : blocks
411 let chapterHeaderLevel = writerEpubChapterLevel opts
411 let chapterHeaderLevel = writerEpubChapterLevel opts
412 -- internal reference IDs change when we chunk the file,
412 -- internal reference IDs change when we chunk the file,
@@ -484,7 +484,7 @@ writeEPUB opts doc@(Pandoc meta _) = do
484 [("id", toId $ eRelativePath ent),
484 [("id", toId $ eRelativePath ent),
485 ("href", eRelativePath ent),
485 ("href", eRelativePath ent),
486 ("media-type", fromMaybe "" $ getMimeType $ eRelativePath ent)] $ ()
486 ("media-type", fromMaybe "" $ getMimeType $ eRelativePath ent)] $ ()
487− let plainTitle = case docTitle meta of
487+ let plainTitle = case docTitle' meta of
488 [] -> case epubTitle metadata of
488 [] -> case epubTitle metadata of
489 [] -> "UNTITLED"
489 [] -> "UNTITLED"
490 (x:_) -> titleText x
490 (x:_) -> titleText x
@@ -524,9 +524,10 @@ writeEPUB opts doc@(Pandoc meta _) = do
524 Just _ -> [ unode "itemref" !
524 Just _ -> [ unode "itemref" !
525 [("idref", "cover_xhtml"),("linear","no")] $ () ]
525 [("idref", "cover_xhtml"),("linear","no")] $ () ]
526 ++ ((unode "itemref" ! [("idref", "title_page_xhtml")
526 ++ ((unode "itemref" ! [("idref", "title_page_xhtml")
527− ,("linear", if null (docTitle meta)
527+ ,("linear",
528− then "no"
528+ case lookupMeta "title" meta of
529− else "yes")] $ ()) :
529+ Just _ -> "yes"
530+ Nothing -> "no")] $ ()) :
530 (unode "itemref" ! [("idref", "nav")
531 (unode "itemref" ! [("idref", "nav")
531 ,("linear", if writerTableOfContents opts
532 ,("linear", if writerTableOfContents opts
532 then "yes"
533 then "yes"
@@ -578,7 +579,7 @@ writeEPUB opts doc@(Pandoc meta _) = do
578 ] ++ subs
579 ] ++ subs
580 let tpNode = unode "navPoint" ! [("id", "navPoint-0")] $
581 let tpNode = unode "navPoint" ! [("id", "navPoint-0")] $
581− [ unode "navLabel" $ unode "text" (stringify $ docTitle meta)
582+ [ unode "navLabel" $ unode "text" (stringify $ docTitle' meta)
582 , unode "content" ! [("src","title_page.xhtml")] $ () ]
583 , unode "content" ! [("src","title_page.xhtml")] $ () ]
584 let tocData = UTF8.fromStringLazy $ ppTopElement $
585 let tocData = UTF8.fromStringLazy $ ppTopElement $
@@ -597,7 +598,7 @@ writeEPUB opts doc@(Pandoc meta _) = do
597 Nothing -> []
598 Nothing -> []
598 Just img -> [unode "meta" ! [("name","cover"),
599 Just img -> [unode "meta" ! [("name","cover"),
599 ("content", toId img)] $ ()]
600 ("content", toId img)] $ ()]
600− , unode "docTitle" $ unode "text" $ plainTitle
601+ , unode "docTitle'" $ unode "text" $ plainTitle
601 , unode "navMap" $
602 , unode "navMap" $
602 tpNode : evalState (mapM (navPointNode navMapFormatter) secs) 1
603 tpNode : evalState (mapM (navPointNode navMapFormatter) secs) 1
@@ -1192,3 +1193,16 @@ relatorMap =
1192 ,("writer of added text", "wat")
1193 ,("writer of added text", "wat")
1196+docTitle' :: Meta -> [Inline]
1197+docTitle' meta = fromMaybe [] $ go <$> lookupMeta "title" meta
1198+ where go (MetaString s) = [Str s]
1199+ go (MetaInlines xs) = xs
1200+ go (MetaBlocks [Para xs]) = xs
1201+ go (MetaBlocks [Plain xs]) = xs
1203+ case M.lookup "type" m of
1204+ Just x | stringify x == "main" ->
1205+ maybe [] go $ M.lookup "text" m
1207+ go (MetaList xs) = concatMap go xs