|
34 | 34 | * Change it when the markdown is not in English. |
35 | 35 | * |
36 | 36 | * This label is typically hidden visually (assuming a `sr-only` CSS class |
37 | | - * is defined that does that), and thus affects screen readers only. |
| 37 | + * is defined that does that) and so affects screen readers only. |
| 38 | + * If you do have such a class, but want to show this section to everyone, |
| 39 | + * pass different attributes with the `labelAttributes` option. |
| 40 | + * @property {string} [labelAttributes='class="sr-only"'] |
| 41 | + * Attributes to use on the footnote label. |
| 42 | + * |
| 43 | + * Change it to show the label and add other attributes. |
| 44 | + * |
| 45 | + * This label is typically hidden visually (assuming an `sr-only` CSS class |
| 46 | + * is defined that does that) and so affects screen readers only. |
| 47 | + * If you do have such a class, but want to show this section to everyone, |
| 48 | + * pass an empty string. |
| 49 | + * You can also add different attributes. |
| 50 | + * |
| 51 | + * > 👉 **Note**: `id="footnote-label"` is always added, because footnote |
| 52 | + * > calls use it with `aria-describedby` to provide an accessible label. |
38 | 53 | * @property {string} [labelTagName='h2'] |
39 | 54 | * HTML tag name to use for the footnote label element. |
40 | 55 | * |
|
43 | 58 | * This label is typically hidden visually (assuming a `sr-only` CSS class |
44 | 59 | * is defined that does that) and so affects screen readers only. |
45 | 60 | * If you do have such a class, but want to show this section to everyone, |
46 | | - * pass different attributes with the `gfm_footnote_label_attributes` |
47 | | - * option. |
| 61 | + * pass different attributes with the `labelAttributes` option. |
48 | 62 | * @property {string} [backLabel='Back to content'] |
49 | 63 | * Textual label to describe the backreference back to footnote calls. |
50 | 64 | * |
@@ -79,9 +93,13 @@ export function gfmFootnoteHtml(options) { |
79 | 93 | const config = options || emptyOptions |
80 | 94 | const label = config.label || 'Footnotes' |
81 | 95 | const labelTagName = config.labelTagName || 'h2' |
| 96 | + const labelAttributes = |
| 97 | + config.labelAttributes === null || config.labelAttributes === undefined |
| 98 | + ? 'class="sr-only"' |
| 99 | + : config.labelAttributes |
82 | 100 | const backLabel = config.backLabel || 'Back to content' |
83 | 101 | const clobberPrefix = |
84 | | - config.clobberPrefix === undefined || config.clobberPrefix === null |
| 102 | + config.clobberPrefix === null || config.clobberPrefix === undefined |
85 | 103 | ? 'user-content-' |
86 | 104 | : config.clobberPrefix |
87 | 105 | return { |
@@ -200,7 +218,9 @@ export function gfmFootnoteHtml(options) { |
200 | 218 | this.tag( |
201 | 219 | '<section data-footnotes="" class="footnotes"><' + |
202 | 220 | labelTagName + |
203 | | - ' id="footnote-label" class="sr-only">' |
| 221 | + ' id="footnote-label"' + |
| 222 | + (labelAttributes ? ' ' + labelAttributes : '') + |
| 223 | + '>' |
204 | 224 | ) |
205 | 225 | this.raw(this.encode(label)) |
206 | 226 | this.tag('</' + labelTagName + '>') |
|
0 commit comments