@@ -521,7 +521,9 @@ footnoteSection opts notes = do
521521 , epubVersion == Just EPUB3
522522 = H5.section ! A.class_ "footnotes"
523523 ! customAttribute "epub:type" "footnotes" $ x
524− | html5 = H5.section ! A.class_ "footnotes" $ x
524+ | html5 = H5.section ! A.class_ "footnotes"
525+ ! customAttribute "role" "doc-endnotes"
526+ $ x
525527 | slideVariant /= NoSlides = H.div ! A.class_ "footnotes slide" $ x
526528 | otherwise = H.div ! A.class_ "footnotes" $ x
527529 return $
@@ -1183,6 +1185,8 @@ inlineToHtml opts inline = do
11831185 $ toHtml ref
11841186 return $ case epubVersion of
11851187 Just EPUB3 -> link ! customAttribute "epub:type" "noteref"
1188+ _ | html5 -> link ! H5.customAttribute
1189+ "role" "doc-noteref"
11861190 _ -> link
11871191 (Cite cits il)-> do contents <- inlineListToHtml opts il
11881192 let citationIds = unwords $ map citationId cits
@@ -1191,12 +1195,17 @@ inlineToHtml opts inline = do
11911195 then result ! customAttribute "data-cites" (toValue citationIds)
11921196 else result
11931197
1194−blockListToNote :: PandocMonad m => WriterOptions -> String -> [Block] -> StateT WriterState m Html
1195−blockListToNote opts ref blocks =
1198+blockListToNote :: PandocMonad m
1199+ => WriterOptions -> String -> [Block]
1200+ -> StateT WriterState m Html
1201+blockListToNote opts ref blocks = do
1202+ html5 <- gets stHtml5
11961203 -- If last block is Para or Plain, include the backlink at the end of
11971204 -- that block. Otherwise, insert a new Plain block with the backlink.
1198− let backlink = [Link ("",["footnote-back"],[]) [Str "↩"] ("#" ++ "fnref" ++ ref,[])]
1199− blocks' = if null blocks
1205+ let kvs = if html5 then [("role","doc-backlink")] else []
1206+ let backlink = [Link ("",["footnote-back"],kvs)
1207+ [Str "↩"] ("#" ++ "fnref" ++ ref,[])]
1208+ let blocks' = if null blocks
12001209 then []
12011210 else let lastBlock = last blocks
12021211 otherBlocks = init blocks
@@ -1207,13 +1216,16 @@ blockListToNote opts ref blocks =
12071216 [Plain (lst ++ backlink)]
12081217 _ -> otherBlocks ++ [lastBlock,
12091218 Plain backlink]
1210− in do contents <- blockListToHtml opts blocks'
1211− let noteItem = H.li ! prefixedId opts ("fn" ++ ref) $ contents
1212− epubVersion <- gets stEPUBVersion
1213− let noteItem' = case epubVersion of
1214− Just EPUB3 -> noteItem ! customAttribute "epub:type" "footnote"
1215− _ -> noteItem
1216− return $ nl opts >> noteItem'
1219+ contents <- blockListToHtml opts blocks'
1220+ let noteItem = H.li ! prefixedId opts ("fn" ++ ref) $ contents
1221+ epubVersion <- gets stEPUBVersion
1222+ let noteItem' = case epubVersion of
1223+ Just EPUB3 -> noteItem !
1224+ customAttribute "epub:type" "footnote"
1225+ _ | html5 -> noteItem !
1226+ customAttribute "role" "doc-endnote"
1227+ _ -> noteItem
1228+ return $ nl opts >> noteItem'
12171229
12181230isMathEnvironment :: String -> Bool
12191231isMathEnvironment s = "\\begin{" `isPrefixOf` s &&
@@ -1434,6 +1446,7 @@ html5Attributes = Set.fromList
14341446 , "rel"
14351447 , "required"
14361448 , "reversed"
1449+ , "role"
14371450 , "rows"
14381451 , "rowspan"
14391452 , "sandbox"