Skip to content

Commit 3025d58

Browse files
committed
add screen-reader-only callout type when appropriate (#726)
1 parent b278972 commit 3025d58

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/resources/filters/modules/callouts.lua

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,11 @@ local calloutidx = 1
191191
local function calloutDiv(node)
192192
node = decorate_callout_title_with_crossref(node)
193193

194+
local needs_screen_reader_callout_type = true
195+
if is_valid_ref_type(refType(node.attr.identifier)) then
196+
needs_screen_reader_callout_type = false
197+
end
198+
194199
-- the first heading is the title
195200
local div = pandoc.Div({})
196201
local c = quarto.utils.as_blocks(node.content)
@@ -218,6 +223,7 @@ local function calloutDiv(node)
218223

219224
if calloutAppearance == _quarto.modules.constants.kCalloutAppearanceDefault and pandoc.utils.stringify(title) == "" and not found then
220225
title = quarto.utils.as_inlines(pandoc.Plain(displayName(node.type)))
226+
needs_screen_reader_callout_type = false
221227
end
222228

223229
-- Make an outer card div and transfer classes and id
@@ -262,6 +268,12 @@ local function calloutDiv(node)
262268
-- show a titled callout
263269
if title ~= nil and (pandoc.utils.type(title) == "string" or next(title) ~= nil) then
264270

271+
if needs_screen_reader_callout_type then
272+
-- add a screen reader callout type
273+
local srCalloutType = pandoc.Span(pandoc.Str(displayName(callout_type)))
274+
srCalloutType.attr.classes:insert("screen-reader-only")
275+
title:insert(1, srCalloutType)
276+
end
265277
-- mark the callout as being titleed
266278
calloutDiv.attr.classes:insert("callout-titled")
267279

src/resources/formats/html/bootstrap/_bootstrap-rules.scss

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2192,3 +2192,15 @@ a {
21922192
font-weight: $link-weight;
21932193
text-decoration: $link-decoration;
21942194
}
2195+
2196+
// screen-reader-only, cf https://github.com/quarto-dev/quarto-cli/issues/726#issuecomment-1112486100
2197+
.screen-reader-only {
2198+
position: absolute;
2199+
clip: rect(0 0 0 0);
2200+
border: 0;
2201+
height: 1px;
2202+
margin: -1px;
2203+
overflow: hidden;
2204+
padding: 0;
2205+
width: 1px;
2206+
}

0 commit comments

Comments
 (0)