Skip to content

Function: extractMarkdownHeadingSection() ​

ts
function extractMarkdownHeadingSection(rawMarkdown, heading): string;

Defined in: markdown/src/parser/internal/parse-markdown-frontmatter.ts:57

Extracts the Markdown body text under a specific ATX heading up to the next heading of equal or higher rank.

Walks top-level mdast heading nodes (ignoring # lines inside fenced code blocks) and slices the section content up to the next heading with depth <= targetDepth.

Parameters ​

ParameterTypeDescription
rawMarkdownstringRaw UTF-8 Markdown document text.
headingstringTarget heading title (with or without leading # characters).

Returns ​

string

Trimmed Markdown content beneath heading.

Throws ​

If heading is not found in rawMarkdown.

Released under the MIT License.