Get-MarkdownMetadata
从 markdown 文件的标头获取元数据。
语法
FromPath (默认值)
Get-MarkdownMetadata
-Path <String[]>
[<CommonParameters>]
FromMarkdownString
Get-MarkdownMetadata
-Markdown <String>
[<CommonParameters>]
说明
Get-MarkdownMetadata cmdlet 从 PlatyPS 支持的 markdown 文件的标头获取元数据。 该命令将元数据作为哈希表返回。
PlatyPS 将 markdown 文件的标头块中的元数据存储为字符串的键值对。 默认情况下,PlatyPS 存储帮助文件名和 Markdown 架构版本。
元数据部分可以包含用于外部工具的用户提供的值。 New-ExternalHelp cmdlet 将忽略此元数据。
示例
示例 1:从文件获取元数据
PS C:\> Get-MarkdownMetadata -Path ".\docs\Get-MarkdownMetadata.md"
Key Value
--- -----
external help file platyPS-help.xml
schema 2.0.0
此命令从 markdown 文件检索元数据。
示例 2:从 markdown 字符串获取元数据
PS C:\> $Markdown = Get-Content -Path ".\docs\Get-MarkdownMetadata.md" -Raw
PS C:\> Get-MarkdownMetadata -Markdown $Markdown
Key Value
--- -----
external help file platyPS-help.xml
schema 2.0.0
第一个命令获取文件的内容,并将其存储在 $Markdown 变量中。
第二个命令从$Metadata中的字符串中检索元数据。
示例 3:从文件夹中的所有文件获取元数据
PS C:\> Get-MarkdownMetadata -Path ".\docs"
Key Value
--- -----
external help file platyPS-help.xml
schema 2.0.0
external help file platyPS-help.xml
schema 2.0.0
external help file platyPS-help.xml
schema 2.0.0
external help file platyPS-help.xml
schema 2.0.0
external help file platyPS-help.xml
schema 2.0.0
external help file platyPS-help.xml
schema 2.0.0
external help file platyPS-help.xml
schema 2.0.0
external help file platyPS-help.xml
schema 2.0.0
此命令从 .\docs 文件夹中的每个 markdown 文件获取元数据。
参数
-Markdown
指定包含 markdown 格式文本的字符串。
参数属性
| 类型: | String |
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
参数集
FromMarkdownString
| Position: | Named |
| 必需: | True |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | False |
| 来自剩余参数的值: | False |
-Path
指定 markdown 文件或文件夹的路径数组。
参数属性
| 类型: | String[] |
| 默认值: | None |
| 支持通配符: | True |
| 不显示: | False |
参数集
FromPath
| Position: | Named |
| 必需: | True |
| 来自管道的值: | True |
| 来自管道的值(按属性名称): | True |
| 来自剩余参数的值: | False |
CommonParameters
此 cmdlet 支持通用参数:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 有关详细信息,请参阅 about_CommonParameters。
输入
String
可以通过管道将路径数组传递给此 cmdlet。
输出
Dictionary
该 cmdlet 返回 Dictionary[String, String] 对象。 字典包含 markdown 元数据块中找到的键值对。