From 9abb458cbbcf93f6cd0f435c26ce67d77762e3ac Mon Sep 17 00:00:00 2001
From: John MacFarlane <jgm@berkeley.edu>
Date: Sun, 10 Feb 2019 18:15:55 -0800
Subject: Implement aria roles doc-bibliography, doc-biblioentry,
 doc-biblioref.

Note that doc-biblioref is only used when link-citations produces
links, since it belongs on links.

See #4213.
---
 src/Text/Pandoc/Writers/HTML.hs | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

(limited to 'src/Text')

diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs
index 2ae3d819c..6fb4bbfb1 100644
--- a/src/Text/Pandoc/Writers/HTML.hs
+++ b/src/Text/Pandoc/Writers/HTML.hs
@@ -731,7 +731,10 @@ blockToHtml opts (Div attr@(ident, classes, kvs') bs) = do
   slideVariant <- gets stSlideVariant
   let kvs = [(k,v) | (k,v) <- kvs', k /= "width"] ++
             [("style", "width:" ++ w ++ ";")
-             | ("width",w) <- kvs', "column" `elem` classes]
+             | ("width",w) <- kvs', "column" `elem` classes] ++
+            [("role", "doc-bibliography") | ident == "refs" && html5] ++
+            [("role", "doc-biblioentry")
+              | "ref-item" `isPrefixOf` ident && html5]
   let speakerNotes = "notes" `elem` classes
   -- we don't want incremental output inside speaker notes, see #1394
   let opts' = if | speakerNotes -> opts{ writerIncremental = False }
@@ -1188,13 +1191,18 @@ inlineToHtml opts inline = do
                                       _ | html5  -> link ! H5.customAttribute
                                                       "role" "doc-noteref"
                                       _          -> link
-    (Cite cits il)-> do contents <- inlineListToHtml opts il
+    (Cite cits il)-> do contents <- inlineListToHtml opts (walk addRoleToLink il)
                         let citationIds = unwords $ map citationId cits
                         let result = H.span ! A.class_ "citation" $ contents
                         return $ if html5
                                     then result ! customAttribute "data-cites" (toValue citationIds)
                                     else result
 
+addRoleToLink :: Inline -> Inline
+addRoleToLink (Link (id',classes,kvs) ils (src,tit)) =
+  Link (id',classes,("role","doc-biblioref"):kvs) ils (src,tit)
+addRoleToLink x = x
+
 blockListToNote :: PandocMonad m
                 => WriterOptions -> String -> [Block]
                 -> StateT WriterState m Html
-- 
cgit v1.2.3