Update in-page.md with more explicit directions for using {:toc} (#1551)

Fixes #1536.
This commit is contained in:
Seb James
2025-01-06 08:32:27 +00:00
committed by GitHub
parent 31f5744f1f
commit 676b33aefe
2 changed files with 24 additions and 5 deletions

View File

@@ -19,6 +19,27 @@ To support in-page navigation, you can generate a *Table of Contents* (TOC) with
To generate a *Table of Contents* in a page, you use Kramdown's `{:toc}` method, immediately after the start of a list. This will automatically generate a list of anchor links to various sections of the page, based on headings and heading levels.
{: .note }
`{:toc}` can be used only once on each page.
You **must** have a list immediately preceding the table of contents. The type of list determines the style of your table of contents.
For an *ordered* table of contents, use the following markdown code:
```md
1. TOC
{:toc}
```
The `{:toc}` line *must* follow the `1. TOC` line, which begins a list.
For an *unordered* table of contents, instead use the following markdown code:
```
- TOC
{:toc}
```
## Omitting Heading from Table of Contents
If you want to omit a particular heading from the TOC, follow it immediately by `{: .no_toc }` (possibly together with other CSS class names).
@@ -36,8 +57,6 @@ If you want to omit a particular heading from the TOC, follow it immediately by
This example omits the top-level heading (`In-Page Navigation`) from the TOC, as well as the heading for the *Table of Contents* itself.
To get an unordered list, replace `1. TOC` by `- TOC` in the above example.
## Collapsible Table of Contents (with `<details>` and `<summary>`)
You can make the Table of Contents collapsible using the `<details>` and `<summary>` elements, as in the following example.
@@ -55,9 +74,6 @@ You can make the Table of Contents collapsible using the `<details>` and `<summa
The attribute `open` (which expands the Table of Contents by default) and the styling (here with `text-delta`) are optional.
{: .note }
`{:toc}` can be used only once on each page.
## Back to Top {#back-to-top-doc}
{: .warning }