[Repo Assist] Add (*** include-toc ***) directive for inline table of contents in literate F# scripts#1058
Draft
github-actions[bot] wants to merge 2 commits intomainfrom
Draft
Conversation
…iterate F# scripts Implements issue #163. Adds a new LiterateParagraph case TableOfContents and a new transformation generateTableOfContents that replaces it with a ListBlock of DirectLink elements pointing to all heading anchors in the document. Usage in .fsx literate scripts: (*** include-toc ***) - list all headings up to depth 3 (*** include-toc:2 ***) - list headings up to depth 2 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This PR was created by Repo Assist, an automated AI assistant.
Closes #163
Summary
Implements the long-requested in-page table of contents directive for literate F# scripts (
.fsxfiles).Usage
In any literate
.fsxfile, place one of these commands where you want the TOC to appear:The directive generates an unordered list of hyperlinks pointing to the heading anchors in the rendered HTML. It requires
generateAnchors = true(the default infsdocs build).Example
Renders the TOC as links to
#Section-Oneand#Section-Two.Implementation
Document.fs: NewTableOfContents of maxDepth: int * paragraphOptions: LiterateParagraphOptionscase onLiterateParagraph.ParseScript.fs: Handles(*** include-toc ***)and(*** include-toc:N ***)commands intransformBlocks, defaulting depth to 3.Transformations.fs: NewgenerateTableOfContentsfunction that collects allHeadingnodes, computes anchor names using the same algorithm asHtmlFormatting.formatAnchor(includingUniqueNameGeneratorsimulation for duplicate headings), and replaces eachTableOfContentsparagraph with aListBlockofDirectLinkspans.Formatting.fs:generateTableOfContentsis called as the first step intransformDocument, beforereplaceLiterateParagraphs.Test Status
FSharp.Literate.Tests)