diff --git a/src/html.c b/src/html.c index 12d3c3e9c..529e0ea31 100644 --- a/src/html.c +++ b/src/html.c @@ -63,10 +63,16 @@ static bool S_put_footnote_backref(cmark_html_renderer *renderer, cmark_strbuf * if (renderer->written_footnote_ix >= renderer->footnote_ix) return false; renderer->written_footnote_ix = renderer->footnote_ix; + char m[32]; + snprintf(m, sizeof(m), "%d", renderer->written_footnote_ix); cmark_strbuf_puts(html, "as.literal.data, node->as.literal.len); - cmark_strbuf_puts(html, "\" class=\"footnote-backref\" data-footnote-backref aria-label=\"Back to content\">↩"); + cmark_strbuf_puts(html, "\" class=\"footnote-backref\" data-footnote-backref data-footnote-backref-idx=\""); + cmark_strbuf_puts(html, m); + cmark_strbuf_puts(html, "\" aria-label=\"Back to reference "); + cmark_strbuf_puts(html, m); + cmark_strbuf_puts(html, "\">↩"); if (node->footnote.def_count > 1) { @@ -78,7 +84,15 @@ static bool S_put_footnote_backref(cmark_html_renderer *renderer, cmark_strbuf * houdini_escape_href(html, node->as.literal.data, node->as.literal.len); cmark_strbuf_puts(html, "-"); cmark_strbuf_puts(html, n); - cmark_strbuf_puts(html, "\" class=\"footnote-backref\" data-footnote-backref aria-label=\"Back to content\">↩"); + cmark_strbuf_puts(html, "\" class=\"footnote-backref\" data-footnote-backref data-footnote-backref-idx=\""); + cmark_strbuf_puts(html, m); + cmark_strbuf_puts(html, "-"); + cmark_strbuf_puts(html, n); + cmark_strbuf_puts(html, "\" aria-label=\"Back to reference "); + cmark_strbuf_puts(html, m); + cmark_strbuf_puts(html, "-"); + cmark_strbuf_puts(html, n); + cmark_strbuf_puts(html, "\">↩"); cmark_strbuf_puts(html, n); cmark_strbuf_puts(html, ""); } diff --git a/test/extensions.txt b/test/extensions.txt index a1a150faa..fe98fe548 100644 --- a/test/extensions.txt +++ b/test/extensions.txt @@ -737,7 +737,7 @@ Hi!
  1. -

    Some bolded footnote definition.

    +

    Some bolded footnote definition.

  2. @@ -745,15 +745,15 @@ Hi!
    as well as code blocks
     
    -

    or, naturally, simple paragraphs.

    +

    or, naturally, simple paragraphs.

  3. -

    no code block here (spaces are stripped away)

    +

    no code block here (spaces are stripped away)

  4. this is now a code block (8 spaces indentation)
     
    - +
@@ -773,7 +773,7 @@ This footnote is referenced[^a-footnote] multiple times, in lots of different pl
  1. -

    This footnote definition should have three backrefs. 2 3

    +

    This footnote definition should have three backrefs. 2 3

@@ -790,7 +790,7 @@ Hello[^">]
  1. -

    pwned

    +

    pwned

diff --git a/test/regression.txt b/test/regression.txt index 844da60a2..1334a674a 100644 --- a/test/regression.txt +++ b/test/regression.txt @@ -194,7 +194,7 @@ A footnote in a paragraph[^1]
  1. -

    a footnote 2

    +

    a footnote 2

@@ -284,10 +284,10 @@ This is some text. It has a citation.[^citation]
  1. -

    This is a long winded parapgraph that also has another citation.2

    +

    This is a long winded parapgraph that also has another citation.2

  2. -

    My second citation.

    +

    My second citation.

@@ -306,10 +306,10 @@ This is some text. It has two footnotes references, side-by-side without any spa
  1. -

    Hello.

    +

    Hello.

  2. -

    Goodbye.

    +

    Goodbye.

@@ -331,10 +331,10 @@ It has another footnote that contains many different characters (the autolinker
  1. -

    this renders properly.

    +

    this renders properly.

  2. -

    so does this.

    +

    so does this.