Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Get-OfficeMarkdownFrontMatter

Module
PSWriteOffice
Inputs
OfficeIMO.Markdown.MarkdownDocument System.String
Outputs
System.Management.Automation.PSObject

Gets top-level YAML or TOML front matter entries from a Markdown document as Key, Value, Node and SourceSpan objects.

Syntax

Get-OfficeMarkdownFrontMatter
[-CaseSensitive]
[-Document <MarkdownDocument>]
[-Key <String>]
[<CommonParameters>]
#
Parameter set: Document
Get-OfficeMarkdownFrontMatter
[-CaseSensitive]
[-Key <String>]
[-Options <Object[]>]
[-Path] <String>
[<CommonParameters>]
#
Parameter set: Path
Get-OfficeMarkdownFrontMatter
[-CaseSensitive]
[-Key <String>]
-LiteralPath <String>
[-Options <Object[]>]
[<CommonParameters>]
#
Parameter set: LiteralPath
Get-OfficeMarkdownFrontMatter
[-CaseSensitive]
[-Key <String>]
[-Options <Object[]>]
-Text <String>
[<CommonParameters>]
#
Parameter set: Text

Description

Gets YAML front matter entries from a Markdown document.

Examples

Read selected front matter from a Markdown file.

$metadata = Get-OfficeMarkdownFrontMatter -Path .\Report.md -Key 'title'
$metadata |
    Select-Object -Property Key, Value |
    Format-Table -AutoSize

Parses a Markdown file and returns matching front matter entries for metadata proof.

Parse front matter from generated text.

$markdown = "---`ntitle: Report`nstatus: Ready`n---`n# Report"
Get-OfficeMarkdownFrontMatter -Text $markdown |
    Select-Object -Property Key, Value

Parses Markdown text directly when the document has not been saved yet.

Parameters

-CaseSensitive SwitchParameter optional
Use case-sensitive matching for key filters.
-Document MarkdownDocument optionalpipeline: True (ByValue)sets: Document
Caller-owned document; omission uses the enclosing Markdown document.
-Key String optional
Optional wildcard pattern matched against front matter keys.
-Options Object[] optionalsets: Path, LiteralPath, Text
Native reader options and optional native-property hashtable overrides.
-Path String requiredposition: 0pipeline: True (ByValue)sets: Path
Input file with FileSystem wildcard expansion.
-LiteralPath String requiredpipeline: True (ByPropertyName)aliases: FullName, PSPathsets: LiteralPath
Literal input file, including a FileInfo pipeline.
-Text String requiredsets: Text
Markdown source text.

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.