FrontMatterBlock
OfficeIMO.Markdown
YAML front matter at the start of a document, read and written by OfficeIMO.Yaml. FrontMatterBlock.Yaml holds the lossless document: nested values are reachable through it, edits made to it are saved with only the changed text rewritten, and an unedited block renders back to the bytes it was read from.
Inheritance
- MarkdownObject
- MarkdownBlock
- FrontMatterBlock
Usage
Explore 4 API references to this type
This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.
Returned or exposed by 4
Methods
public Entry? FindEntry(string key, StringComparison comparison = OrdinalIgnoreCase) #Finds a top-level entry by key. When keys repeat under the comparison, the last one wins, as it does for YAML loaders that accept repeated keys.
Parameters
- key string
- comparison System.StringComparison = OrdinalIgnoreCase
Returns
Entry?public static FrontMatterBlock FromObject(object data) #Creates front matter from an anonymous object, a dictionary or another object's public properties. Nested dictionaries, objects and collections become YAML mappings and sequences, and YamlNode values are used as they are.
Parameters
- data object
Returns
FrontMatterBlockpublic static FrontMatterBlock FromObject<T>(T? data) #Creates front matter from a typed object's public properties or from a dictionary. Nested dictionaries and collections become YAML mappings and sequences; other nested objects are written as their invariant text.
Type Parameters
- T
Parameters
- data T?
Returns
FrontMatterBlockpublic bool HasEntry(string key, StringComparison comparison = OrdinalIgnoreCase) #Checks whether the front matter has a top-level entry with the key.
Parameters
- key string
- comparison System.StringComparison = OrdinalIgnoreCase
Returns
boolpublic string Render() #Renders the front matter with its fences. Unedited front matter read from Markdown renders the text it was read from; edits made through FrontMatterBlock.Yaml rewrite only what changed.
Returns
stringpublic YamlNode? Select(string path) #Returns the node a YAML path such as author.name or tags[0] addresses, or null.
Parameters
- path string
Returns
YamlNode?public bool TryGetValue<T>(string key, out T? value) #Reads a top-level scalar entry as T through the YAML schema, as YamlNode.TryGetValue does: string, bool, int, long, double, float, decimal and their nullable forms. Returns false when the key is missing, the value is a collection or it does not convert.
Type Parameters
- T
Parameters
- key string
- value T?
Returns
boolExceptions
NotSupportedException– T is not a supported type.
Inherited Methods
public void Accept(MarkdownVisitor visitor) #Parameters
- visitor MarkdownVisitor
public IEnumerable<MarkdownObject> Ancestors() #Returns
IEnumerable<MarkdownObject>public IEnumerable<MarkdownObject> AncestorsAndSelf() #Returns
IEnumerable<MarkdownObject>public IEnumerable<TObject> DescendantObjectsOfType<TObject>() #Type Parameters
- TObject
Returns
IEnumerable<TObject>public IEnumerable<MarkdownObject> Descendants() #Returns
IEnumerable<MarkdownObject>Properties
public YamlDocument? Yaml { get; } #Gets the YAML document, or null when the text between the fences is not valid YAML; then FrontMatterBlock.Diagnostics holds the error and the block renders FrontMatterBlock.RawYaml unchanged.
public YamlMapping? Mapping { get; } #Gets the root mapping of the front matter, or null when it is empty, invalid or not a mapping.
public IReadOnlyList<Entry> Entries { get; } #Gets the top-level entries of FrontMatterBlock.Mapping in source order, with Markdown source spans for entries that were read from Markdown. The list follows edits made through FrontMatterBlock.Yaml.
public string? RawYaml { get; } #Gets the text between the fences as it was read from Markdown, or null for front matter built in code.
public MarkdownSourceSpan? BodySourceSpan { get; } #Gets the source span of the text between the fences when parsed from Markdown.
public IReadOnlyList<OfficeDiagnostic> Diagnostics { get; } #Gets findings from reading the front matter: a OfficeDiagnosticCodes.MarkdownFrontMatterInvalidYaml error located in the Markdown source when the YAML is invalid, and otherwise the YAML document's own findings, such as repeated keys, located within the front matter text.
Inherited Properties
public MarkdownSourceSpan? SourceSpan { get; internal set; } #public IReadOnlyList<MarkdownObject> ChildObjects { get; } #