Markdown.TryExtractFrontMatter Method

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

Definition

Attempts to extract and parse the front matter block from Markdown content.
public static bool TryExtractFrontMatter(ReadOnlySpan<char> content, out IReadOnlyDictionary<string, object> frontMatter, out int contentStart)

Parameters

content ReadOnlySpan<char>
The Markdown content to inspect.
frontMatter IReadOnlyDictionary<string, object>
When this method returns, contains the parsed front matter metadata if found; otherwise, an empty dictionary.
contentStart int
When this method returns, contains the index in content at which the body content starts.

Returns

bool
true if a front matter block was found and parsed; otherwise, false.

Exceptions

FormatException
Thrown when a front matter block is found but cannot be parsed as valid YAML.

Remarks

Front matter must start at the very beginning of the document, delimited by --- on its own line. The closing delimiter may be either --- or ....