Markdown.EnumerateHeadings Method

Namespace
Kampute.DocToolkit.Support
Assembly
  • Kampute.DocToolkit.dll

Definition

Enumerates all ATX-style headings in the given Markdown content, returning their text and corresponding levels.
public static IEnumerable<ValueTuple<int, string>> EnumerateHeadings(string content)

Parameters

content string
The Markdown content to inspect.

Returns

IEnumerable<ValueTuple<int, string>>
An enumerable of tuples, each containing the level and text of a heading found in the content.

Exceptions

ArgumentNullException
Thrown when content is null.

Remarks

A heading is a line that, ignoring leading and trailing whitespace, starts with one to six '#' characters followed by non-empty text. Unlike CommonMark, the text does not need to be separated from the '#' characters by whitespace, so #Title is a heading. An optional closing sequence of '#' characters, when preceded by whitespace, is not part of the heading text, and backslash escapes in the heading text are decoded. Lines inside fenced code blocks are not headings.