Get-MarkdownMetadata
從 Markdown 檔案的標頭取得元數據。
語法
Get-MarkdownMetadata
-Path <String[]>
[<CommonParameters>]
Get-MarkdownMetadata
-Markdown <String>
[<CommonParameters>]
Description
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 |
Position: | Named |
預設值: | None |
必要: | True |
接受管線輸入: | False |
接受萬用字元: | False |
-Path
指定 Markdown 檔案或資料夾的路徑陣列。
類型: | String[] |
Position: | Named |
預設值: | None |
必要: | True |
接受管線輸入: | True |
接受萬用字元: | True |
輸入
String[]
您可以使用管線將路徑陣列傳送至此 Cmdlet。
輸出
Dictionary[String, String]
Cmdlet 會傳回 Dictionary[String, String]
物件。 字典包含 Markdown 元數據區塊中找到的索引鍵/值組。