From 167e52a424c86510d2dc824828c470ad7943953d Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 27 May 2019 22:27:41 -0700 Subject: 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. --- src/Text/Pandoc/Writers/EPUB.hs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs index b0f6adecc..062ab19ed 100644 --- a/src/Text/Pandoc/Writers/EPUB.hs +++ b/src/Text/Pandoc/Writers/EPUB.hs @@ -793,13 +793,8 @@ pandocToEPUB version opts doc = do [("id","toc")]) $ [ unode "h1" ! [("id","toc-title")] $ tocTitle , unode "ol" ! [("class","toc")] $ tocBlocks ]] - let landmarks = if epub3 - then [RawBlock (Format "html") $ ppElement $ - unode "nav" ! [("epub:type","landmarks") - ,("id","landmarks") - ,("hidden","hidden")] $ - [ unode "ol" $ - [ unode "li" + let landmarkItems = if epub3 + then [ unode "li" [ unode "a" ! [("href", "text/cover.xhtml") ,("epub:type", "cover")] $ "Cover"] | @@ -811,9 +806,15 @@ pandocToEPUB version opts doc = do "Table of contents" ] | writerTableOfContents opts ] - ] + else [] + let landmarks = if null landmarkItems + then [] + else [RawBlock (Format "html") $ ppElement $ + unode "nav" ! [("epub:type","landmarks") + ,("id","landmarks") + ,("hidden","hidden")] $ + [ unode "ol" landmarkItems ] ] - else [] navData <- lift $ writeHtml opts'{ writerVariables = ("navpage","true"): cssvars False ++ vars } (Pandoc (setMeta "title" -- cgit v1.2.3