diff options
author | John MacFarlane <jgm@berkeley.edu> | 2014-12-15 20:56:03 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2014-12-15 20:56:03 -0800 |
commit | cb8bb4705ff003ce15b4a99c1dfdfa168e2c2bbd (patch) | |
tree | 251851e05114616974516b4917b281a9b0615feb /src/Text/Pandoc | |
parent | 8a3363a269cda134a60d5061e93d09363b5586af (diff) | |
download | pandoc-cb8bb4705ff003ce15b4a99c1dfdfa168e2c2bbd.tar.gz |
EPUB writer: include "landmarks" section in nav document for epub3.
Closes #1757.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Writers/EPUB.hs | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs index 3f9c6a606..09f696665 100644 --- a/src/Text/Pandoc/Writers/EPUB.hs +++ b/src/Text/Pandoc/Writers/EPUB.hs @@ -343,7 +343,6 @@ writeEPUB opts doc@(Pandoc meta _) = do , writerStandalone = True , writerSectionDivs = True , writerHtml5 = epub3 - , writerTableOfContents = False -- we always have one in epub , writerVariables = vars , writerHTMLMathMethod = if epub3 @@ -612,13 +611,34 @@ writeEPUB opts doc@(Pandoc meta _) = do let navtag = if epub3 then "nav" else "div" let navBlocks = [RawBlock (Format "html") $ ppElement $ - unode navtag ! [("epub:type","toc") | epub3] $ + unode navtag ! ([("epub:type","toc") | epub3] ++ + [("id","toc")]) $ [ unode "h1" ! [("id","toc-title")] $ plainTitle , unode "ol" ! [("class","toc")] $ evalState (mapM (navPointNode navXhtmlFormatter) secs) 1]] + let landmarks = if epub3 + then [RawBlock (Format "html") $ ppElement $ + unode "nav" ! [("epub:type","landmarks") + ,("hidden","hidden")] $ + [ unode "ol" $ + [ unode "li" + [ unode "a" ! [("href", "cover.xhtml") + ,("epub:type", "cover")] $ + "Cover"] | + epubCoverImage metadata /= Nothing + ] ++ + [ unode "li" + [ unode "a" ! [("href", "#toc") + ,("epub:type", "toc")] $ + "Table of contents" + ] | writerTableOfContents opts + ] + ] + ] + else [] let navData = renderHtml $ writeHtml opts' (Pandoc (setMeta "title" (walk removeNote $ fromList $ docTitle' meta) nullMeta) - navBlocks) + (navBlocks ++ landmarks)) let navEntry = mkEntry "nav.xhtml" navData -- mimetype |