From f289b7f13a1dfc7c096b13b5f194aa61dc14075f Mon Sep 17 00:00:00 2001 From: Shulhan Date: Sat, 24 Jan 2026 21:30:35 +0700 Subject: all: add aria-label to the anchor when sectanchor enabled The aria-label help user with screen reader to discern and navigate the anchor. Ref: https://dequeuniversity.com/rules/axe/4.11/link-name --- html_backend.go | 4 +- testdata/test.got.html | 142 ++++++++++++++++++++++++------------------------- 2 files changed, 74 insertions(+), 72 deletions(-) diff --git a/html_backend.go b/html_backend.go index 14137e5..323b60b 100644 --- a/html_backend.go +++ b/html_backend.go @@ -1167,7 +1167,9 @@ func htmlWriteSection(doc *Document, el *element, out io.Writer) { _, withSectAnchors = doc.Attributes.Entry[docAttrSectAnchors] if withSectAnchors { - fmt.Fprintf(out, ``, el.ID) + fmt.Fprintf(out, + ``, + el.ID, el.ID) } _, withSectlinks = doc.Attributes.Entry[docAttrSectLinks] if withSectlinks { diff --git a/testdata/test.got.html b/testdata/test.got.html index f236402..e0162cd 100644 --- a/testdata/test.got.html +++ b/testdata/test.got.html @@ -2604,7 +2604,7 @@ p.tableblock {
-

1. Metadata references

+

1. Metadata references

First author: Author A Author A a@a.com @@ -2624,7 +2624,7 @@ AA.

-

2. Inline formatting on section

+

2. Inline formatting on section

Test inline formatting on section title.

@@ -2632,16 +2632,16 @@ AA.

-

3. Level 1

+

3. Level 1

-

5. Comment

+

5. Comment

@@ -2671,7 +2671,7 @@ Indented block comment
-

6. Paragraph

+

6. Paragraph

A Title
@@ -2729,7 +2729,7 @@ This is next line in paragraph.

-

6.1. Alignment

+

6.1. Alignment

This text is left aligned.

@@ -2744,7 +2744,7 @@ This is next line in paragraph.

-

6.2. Line break

+

6.2. Line break

Rubies are red,
Topazes are blue.

@@ -2767,7 +2767,7 @@ line break

-

7. Unconstrained text formatting

+

7. Unconstrained text formatting

__A *B*__: A B

@@ -2802,7 +2802,7 @@ line break

-

8. Single quote

+

8. Single quote

'` A single quote without end.

@@ -2819,7 +2819,7 @@ line break

-

9. Subscript and superscript

+

9. Subscript and superscript

H20 H~ 3 ~0 H~4 ~0 H ~ 5~0 H~6 7~0.

@@ -2830,7 +2830,7 @@ line break

-

10. Constrained text formatting

+

10. Constrained text formatting

_A_B: _A_B

@@ -2882,10 +2882,10 @@ paragraph.

-

11. Blocks

+

11. Blocks

-

11.1. Title

+

11.1. Title

TODO list
    @@ -2904,7 +2904,7 @@ paragraph.

-

12. Block listing

+

12. Block listing

@@ -2923,7 +2923,7 @@ This is not listing.

-

13. Block literal

+

13. Block literal

@@ -2948,7 +2948,7 @@ A literal named and trailing characters will become paragraph.

-

14. Ordered Lists

+

14. Ordered Lists

    @@ -3171,7 +3171,7 @@ This line separated by comment.

-

15. Unordered Lists

+

15. Unordered Lists

    @@ -3392,7 +3392,7 @@ This line separated by comment.

-

15.1. Custom markers

+

15.1. Custom markers

  • @@ -3541,7 +3541,7 @@ This line separated by comment.

-

15.2. Checklist

+

15.2. Checklist

  • @@ -3562,7 +3562,7 @@ This line separated by comment.

-

16. Mixed list

+

16. Mixed list

    @@ -3638,7 +3638,7 @@ This line separated by comment.

-

17. Description list

+

17. Description list

@@ -3965,7 +3965,7 @@ Hard drive
-

18. Question and Answers

+

18. Question and Answers

    @@ -3985,7 +3985,7 @@ Hard drive
-

19. Table

+

19. Table

@@ -4051,7 +4051,7 @@ D

-

19.2. Cell formatting

+

19.2. Cell formatting

Cell duplicated across three columns,

@@ -4194,7 +4194,7 @@ D

-

19.3. Header row

+

19.3. Header row

@@ -4231,7 +4231,7 @@ D

- + @@ -4264,7 +4264,7 @@ D

-

19.5. Table width

+

19.5. Table width

@@ -4341,9 +4341,9 @@ D

-

19.6. Table borders

+

19.6. Table borders

-

19.6.1. Frame

+

19.6.1. Frame

@@ -4409,7 +4409,7 @@ D

-

19.6.2. Grids

+

19.6.2. Grids

@@ -4476,7 +4476,7 @@ D

@@ -4583,7 +4583,7 @@ D

-

19.8. Orientation

+

19.8. Orientation

@@ -4618,7 +4618,7 @@ D

-

19.9. Table caption

+

19.9. Table caption

@@ -4678,7 +4678,7 @@ D

Table 1. A formal table
-

19.10. Escaping the Cell separator

+

19.10. Escaping the Cell separator

@@ -4707,7 +4707,7 @@ D

-

20. Horizontal rules

+

20. Horizontal rules


@@ -4729,7 +4729,7 @@ D

-

21. Page break

+

21. Page break

Before page break.

@@ -4741,7 +4741,7 @@ D

-

22. URLs

+

22. URLs

https://asciidoctor.org.

@@ -4770,7 +4770,7 @@ D

-

23. Anchors

+

23. Anchors

This paragraph gets a lot of attention.

@@ -4798,21 +4798,21 @@ D

-

23.2. Version 4.10

+

23.2. Version 4.10

-

24. Cross references

+

24. Cross references

-

24.1. Internal

+

24.1. Internal

Cross reference with ID _anchors.

@@ -4829,7 +4829,7 @@ D

-

25. Include

+

25. Include

This is inside the fragment1.adoc.

@@ -4895,10 +4895,10 @@ type anchor struct {
-

26. Images

+

26. Images

-

26.1. Block images

+

26.1. Block images

sunset @@ -4978,7 +4978,7 @@ This is become paragraph.

-

26.2. Float group

+

26.2. Float group

@@ -5000,7 +5000,7 @@ This is become paragraph.

-

26.3. Inline image

+

26.3. Inline image

Linux

@@ -5018,7 +5018,7 @@ You can find Linux everywhere these days!

-

27. Block open

+

27. Block open

Section inside
@@ -5031,7 +5031,7 @@ You can find Linux everywhere these days!

-

28. Video

+

28. Video

Video without options
@@ -5078,7 +5078,7 @@ Your browser does not support the video tag.
-

29. Audio

+

29. Audio

@@ -5090,10 +5090,10 @@ Your browser does not support the audio tag.
-

30. Admonition

+

30. Admonition

-

30.1. Line admonition

+

30.1. Line admonition

Admonition between a paragraph. WARNING: Wolpertingers are known to nest in server racks. @@ -5180,7 +5180,7 @@ admonition followed by list

@@ -5266,7 +5266,7 @@ Literal paragraph with admonition.
@@ -5284,7 +5284,7 @@ Enter at your own risk.
- +
@@ -5314,7 +5314,7 @@ for producing professional documents like DocBook and LaTeX.

-

32. Example

+

32. Example

Example 1. Sample document
@@ -5339,7 +5339,7 @@ This guide provides...
-

33. Quote

+

33. Quote

@@ -5378,7 +5378,7 @@ Everybody remember where we parked.
-

33.1. Quoted paragraph

+

33.1. Quoted paragraph

I hold it that a little rebellion now and then is a good thing, @@ -5439,7 +5439,7 @@ a quote
-

34. Verse

+

34. Verse

The fog comes
@@ -5465,13 +5465,13 @@ and then moves on.
-

35. Passthrough

+

35. Passthrough

A B+

-

35.1. Block passthrough

+

35.1. Block passthrough

@@ -5479,14 +5479,14 @@ and then moves on.
-

36. Section Discrete

+

36. Section Discrete

Discrete

This is content of discrete section.