Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-CORE-072

A [TOC] marker or a contents directive renders the table of contents

When a paragraph holds only [TOC] or [[_TOC_]] (any case), or a MyST contents directive is written, the preview SHALL render in its place the headings of the document as a nested list of links to the headings, limited by the depth option and to the current section by the local option of the directive, generated at render time and never written to the file, and, in edit mode, SHALL show the block as an admonition-like block titled with the literal marker instead of the list.

Part of StRS-MDOKFSTUDIO-CORE-001, outside the paths drawn on its map.

Scenarios 3

The situations the tests check; open one to read it.

nominalTable of contents
Givena document with `[TOC]` (or `[[_TOC_]]`, or `{contents}`) alone in a block and the headings `# A`, `## B`, `## C`, `### D`
Whenthe document is rendered
Thenthe marker is replaced by a `nav` holding a nested list of links `A` > (`B`, `C` > `D`), each pointing to `#` plus the slug of its heading, every heading carries that slug as its `id`, and the saved file still holds only the marker
boundaryDepth, duplicates and exclusions
InputOutcome
`{contents}` with `:depth: 1`only the top level of the list; `:depth: 2` stops after two list levels (a heading that skips a level nests directly under the previous shallower one); without the option, no limit
`{contents}` with `:local:`only the headings of the section the directive is in, after it, down to the next heading as high as the one before it; the rest of the document when no heading precedes it
`[toc]`, `[[_toc_]]`markers too: the match ignores the case
two headings with the same textthe second gets the slug suffix `-1` (then `-2`), like on GitHub
a heading made only of an anchor or empty textnot listed
headings brought in by `{include}`not listed; the scope is the document itself
`[TOC]` or `[[_TOC_]]` inside a code block, inline code, or in a paragraph with other textnot a marker; the usual rendering applies
a document without headingsthe marker renders nothing in read mode
nominalEdit mode
Givenedit mode is on
Whena `[TOC]`, `[[_TOC_]]` or `{contents}` block is rendered
Thenit is shown as an admonition-like block titled with the literal marker in code font, the generated list is hidden, a click edits the marker line only, and read mode shows the list without any frame or title

Implemented in 2

Tested by 3