Project

PSWriteOffice

PowerShell document automation across OfficeIMO's document, spreadsheet, presentation, PDF, Project, Access, EPUB, invoicing, and conversion engines.

Stars 654
Forks 82
Open issues 1
Total downloads 4,320,051
Release OfficeIMO-v3.5.3
Language: C# Updated: 2026-11-03
Cmdlet

Add-OfficeMarkdownTableOfContents

Aliases: MarkdownTableOfContents, MarkdownToc
Module
PSWriteOffice
Aliases
MarkdownTableOfContents MarkdownToc
Inputs
OfficeIMO.Markdown.MarkdownDoc
Outputs
OfficeIMO.Markdown.MarkdownDoc

Adds a Markdown table of contents placeholder.

Syntax

Add-OfficeMarkdownTableOfContents
[-ForPreviousHeading]
[-ForSection <String>]
[-MaxLevel <Int32>]
[-MinLevel <Int32>]
[-Ordered]
[-PassThru]
[-PlaceAtTop]
[-Title <String>]
[-TitleLevel <Int32>]
[<CommonParameters>]
#
Parameter set: Context
Add-OfficeMarkdownTableOfContents
-Document <MarkdownDoc>
[-ForPreviousHeading]
[-ForSection <String>]
[-MaxLevel <Int32>]
[-MinLevel <Int32>]
[-Ordered]
[-PassThru]
[-PlaceAtTop]
[-Title <String>]
[-TitleLevel <Int32>]
[<CommonParameters>]
#
Parameter set: Document

Examples

Add a TOC at the top of a generated report.

New-OfficeMarkdown -Path .\Report.md {
    Add-OfficeMarkdownHeading -Level 1 -Text 'Release Report'
    Add-OfficeMarkdownHeading -Level 2 -Text 'Summary'
    Add-OfficeMarkdownParagraph -Text 'Current state and risks.'
    Add-OfficeMarkdownHeading -Level 2 -Text 'Appendix'
    Add-OfficeMarkdownParagraph -Text 'Supporting evidence.'
    Add-OfficeMarkdownTableOfContents -Title 'Contents' -MinLevel 2 -MaxLevel 3 -PlaceAtTop
}

Inserts a generated table of contents for headings in the document.

Parameters

-ForPreviousHeading SwitchParameter optional
Scope the TOC to the previous heading.
-ForSection String optional
Scope the TOC to the named section heading.
-MaxLevel Int32 optional
Maximum heading depth included in the table of contents.
-MinLevel Int32 optional
Minimum heading depth included in the table of contents.
-Ordered SwitchParameter optional
Generate an ordered table of contents list.
-PassThru SwitchParameter optional
Emit the updated Markdown document.
-PlaceAtTop SwitchParameter optional
Insert the TOC at the start of the document.
-Title String optional
Heading text displayed above the generated table of contents.
-TitleLevel Int32 optional
Heading level used for the TOC title.
-Document MarkdownDoc requiredpipeline: True (ByValue)sets: Document
Markdown document to update outside the DSL context.

Common Parameters

This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.

For more information, see about_CommonParameters.