git.iko.soy/typeable/pandoc
on master help sign in
EPUB writer: include "landmarks" section in nav document for epub3.

Closes #1757.

commitcb8bb4705ff003ce15b4a99c1dfdfa168e2c2bbd authorJohn MacFarlane <jgm@berkeley.edu> dateMon 15 Dec 2014, 20:56 (12 years ago) parent8a3363a
1 file changed+23−3
src/Text/Pandoc/Writers/EPUB.hs+23−3
src/Text/Pandoc/Writers/EPUB.hs+23−3
@@ -343,7 +343,6 @@ writeEPUB opts doc@(Pandoc meta _) = do
343343 , writerStandalone = True
344344 , writerSectionDivs = True
345345 , writerHtml5 = epub3
346− , writerTableOfContents = False -- we always have one in epub
347346 , writerVariables = vars
348347 , writerHTMLMathMethod =
349348 if epub3
@@ -612,13 +611,34 @@ writeEPUB opts doc@(Pandoc meta _) = do
612611
613612 let navtag = if epub3 then "nav" else "div"
614613 let navBlocks = [RawBlock (Format "html") $ ppElement $
615− unode navtag ! [("epub:type","toc") | epub3] $
614+ unode navtag ! ([("epub:type","toc") | epub3] ++
615+ [("id","toc")]) $
616616 [ unode "h1" ! [("id","toc-title")] $ plainTitle
617617 , unode "ol" ! [("class","toc")] $ evalState (mapM (navPointNode navXhtmlFormatter) secs) 1]]
618+ let landmarks = if epub3
619+ then [RawBlock (Format "html") $ ppElement $
620+ unode "nav" ! [("epub:type","landmarks")
621+ ,("hidden","hidden")] $
622+ [ unode "ol" $
623+ [ unode "li"
624+ [ unode "a" ! [("href", "cover.xhtml")
625+ ,("epub:type", "cover")] $
626+ "Cover"] |
627+ epubCoverImage metadata /= Nothing
628+ ] ++
629+ [ unode "li"
630+ [ unode "a" ! [("href", "#toc")
631+ ,("epub:type", "toc")] $
632+ "Table of contents"
633+ ] | writerTableOfContents opts
634+ ]
635+ ]
636+ ]
637+ else []
618638 let navData = renderHtml $ writeHtml opts'
619639 (Pandoc (setMeta "title"
620640 (walk removeNote $ fromList $ docTitle' meta) nullMeta)
621− navBlocks)
641+ (navBlocks ++ landmarks))
622642 let navEntry = mkEntry "nav.xhtml" navData
623643
624644 -- mimetype