Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Piganeau <nicolas.piganeau@ndp-systemes.fr>2020-08-24 20:23:16 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2020-09-06 12:34:32 +0300
commit3ba7c92530a80f2f04fe57705ab05c247a6e8437 (patch)
tree1e3354fcef9ad233632006957a94a50155bc36e6 /docs/content/en/content-management
parent19ef27b98edca53c4138b01c0f7c7bfbeb5ffcf1 (diff)
markup/asciidoc: Add support for .TableOfContents
Fill the .TableOfContents template variable when writing Asciidoc content. This is done by letting Asciidoc render its TOC as HTML, then extract this HTML rendered TOC, parse it into a tableofcontents.Root and finally remove it from the HTML content. This aims to stay in the logic that the Asciidoc parsing is entirely done by the external helper. See #1687
Diffstat (limited to 'docs/content/en/content-management')
-rw-r--r--docs/content/en/content-management/toc.md27
1 files changed, 27 insertions, 0 deletions
diff --git a/docs/content/en/content-management/toc.md b/docs/content/en/content-management/toc.md
index fbb2df065..efc47b4b8 100644
--- a/docs/content/en/content-management/toc.md
+++ b/docs/content/en/content-management/toc.md
@@ -92,6 +92,33 @@ The following is a [partial template][partials] that adds slightly more logic fo
With the preceding example, even pages with > 400 words *and* `toc` not set to `false` will not render a table of contents if there are no headings in the page for the `{{.TableOfContents}}` variable to pull from.
{{% /note %}}
+## Usage with asciidoc
+
+Hugo supports table of contents with Asciidoc content format.
+
+In the header of your content file, specify the Asciidoc TOC directives, by using the macro style:
+
+```asciidoc
+// <!-- Your front matter up here -->
+:toc: macro
+// Set toclevels to be at least your hugo [markup.tableOfContents.endLevel] config key
+:toclevels: 4
+toc::[]
+
+== Introduction
+
+One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin.
+
+== My Heading
+
+He lay on his armour-like back, and if he lifted his head a little he could see his brown belly, slightly domed and divided by arches into stiff sections. The bedding was hardly able to cover it and seemed ready to slide off any moment.
+
+=== My Subheading
+
+A collection of textile samples lay spread out on the table - Samsa was a travelling salesman - and above it there hung a picture that he had recently cut out of an illustrated magazine and housed in a nice, gilded frame. It showed a lady fitted out with a fur hat and fur boa who sat upright, raising a heavy fur muff that covered the whole of her lower arm towards the viewer. Gregor then turned to look out the window at the dull weather. Drops
+```
+Hugo will take this Asciddoc and create a table of contents store it in the page variable `.TableOfContents`, in the same as described for Markdown.
+
[conditionals]: /templates/introduction/#conditionals
[front matter]: /content-management/front-matter/
[pagevars]: /variables/page/