Skip to content

Commit

Permalink
fix doc
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-gui committed Oct 18, 2024
1 parent ec2bf23 commit 2f28783
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions docs/scripts/heading-anchors.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Heading anchors

This script is part of `main.js`/`main.min.js`. To help linking to specific parts of pages, this script automatically creates and appends a visible anchor link to the end of any H2-H6 heading within the `<main>` element, with the following exclusions:
This script is part of `main.js`/`main.min.js`. To help linking to specific parts of pages, this script automatically creates and appends a visible anchor link to the end of any H2-H6 heading that have an `id` attribute within the `<main>` element, with the following exclusions:

- where the heading is a child of a `<nav>` element
- where the heading carries the attribute `data-anchor="no"`, the `hidden` attribute or the `.visuallyhidden` class
- where a heading has an ancestor carrying the attribute `data-anchor="no"`, the `hidden` attribute or the `.visuallyhidden` class

If a heading already has an `id` attribute, this is used when creating the `href` for the `<a>`. Otherwise, the script parses the text content of the heading to create both the heading `id` and the anchor `href`.
The `id` attribute is used when creating the `href` for the `<a>`.

To override the default behaviour of the script and prevent the addition of anchor links to headings, modify the HTML markup to apply the `data-anchor="no"` attribute to an individual heading (or to a parent container, if targeting a group of headings).

Expand All @@ -18,4 +18,4 @@ The `data-anchor="no"` attribute has been added directly to the markup to overri
- [collapsible containers](../components/collapsible-containers.md)
- [evangelists](../components/evangelists.md)
- [group list](../components/group-list.md)
- [notes](../components/notes.md)
- [notes](../components/notes.md)

0 comments on commit 2f28783

Please sign in to comment.