aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2019-05-27 22:27:41 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2019-05-27 22:27:41 -0700
commit167e52a424c86510d2dc824828c470ad7943953d (patch)
treef8525ce5a23d61ac831523dc82a945a7d59056b9 /src
parent3593dcda61b2de2cbd302293d04599957cbdfd4a (diff)
downloadpandoc-167e52a424c86510d2dc824828c470ad7943953d.tar.gz
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.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Writers/EPUB.hs19
1 files changed, 10 insertions, 9 deletions
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"