git.iko.soy/typeable/pandoc
on master help sign in
EPUB writer: don't include 'landmarks' if there aren't any.

Previously we could get an empty ol element, which caused validation errors with epubcheck.

commit167e52a424c86510d2dc824828c470ad7943953d authorJohn MacFarlane <jgm@berkeley.edu> dateMon 27 May 2019, 22:27 (7 years ago) parent3593dcd
1 file changed+10−9
src/Text/Pandoc/Writers/EPUB.hs+10−9
src/Text/Pandoc/Writers/EPUB.hs+10−9
@@ -793,13 +793,8 @@ pandocToEPUB version opts doc = do
793793 [("id","toc")]) $
794794 [ unode "h1" ! [("id","toc-title")] $ tocTitle
795795 , unode "ol" ! [("class","toc")] $ tocBlocks ]]
796− let landmarks = if epub3
797− then [RawBlock (Format "html") $ ppElement $
798− unode "nav" ! [("epub:type","landmarks")
799− ,("id","landmarks")
800− ,("hidden","hidden")] $
801− [ unode "ol" $
802− [ unode "li"
796+ let landmarkItems = if epub3
797+ then [ unode "li"
803798 [ unode "a" ! [("href", "text/cover.xhtml")
804799 ,("epub:type", "cover")] $
805800 "Cover"] |
@@ -811,9 +806,15 @@ pandocToEPUB version opts doc = do
811806 "Table of contents"
812807 ] | writerTableOfContents opts
813808 ]
814− ]
809+ else []
810+ let landmarks = if null landmarkItems
811+ then []
812+ else [RawBlock (Format "html") $ ppElement $
813+ unode "nav" ! [("epub:type","landmarks")
814+ ,("id","landmarks")
815+ ,("hidden","hidden")] $
816+ [ unode "ol" landmarkItems ]
815817 ]
816− else []
817818 navData <- lift $ writeHtml opts'{ writerVariables = ("navpage","true"):
818819 cssvars False ++ vars }
819820 (Pandoc (setMeta "title"