Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions src/MarkdownReader/CommandHelpMarkdownReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,38 @@ internal static CommandHelp GetCommandHelpFromMarkdown(ParsedMarkdownContent mar
return ConvertTextToOrderedDictionary(metadataAsParagraph.Content.Text);
}
}
else if (ast[2] is Markdig.Syntax.ListBlock && ast[1] is ParagraphBlock paragraphWithList)
{
List<string> listItems = new();

if (ast[2] is Markdig.Syntax.ListBlock listBlock)
{
foreach (var listItem in listBlock)
{
if (listItem is ListItemBlock listItemBlock)
{
if (listItemBlock is ContainerBlock containerBlock)
{
if (containerBlock.LastChild is ParagraphBlock paragraphListItem)
{
if (paragraphListItem.Inline?.FirstChild is LiteralInline listItemText)
{
listItems.Add(listItemText.Content.ToString().Trim());
}
}
}
}
}
}

if (paragraphWithList.Inline?.FirstChild is LiteralInline metadataAsParagraph)
{
var metadataDictionary = ConvertTextToOrderedDictionary(metadataAsParagraph.Content.Text);
// update the metadata dictionary with the list items of aliases
metadataDictionary["aliases"] = listItems;
return metadataDictionary;
}
}
}

return null;
Expand Down
16 changes: 16 additions & 0 deletions test/Pester/ImportMarkdownCommandHelp.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,22 @@ Describe 'Import-MarkdownCommandHelp Tests' {
$metadata[$name] | Should -Be $expectedValue

}

It 'Should be able to read metata with alias as list' {
$result = Import-MarkdownCommandHelp -Path "$assetdir/Get-ChildItem-WithListAliases.md"
$result.Metadata.aliases.Count | Should -Be 3
$result.Metadata.aliases[0] | Should -Be "dir"
$result.Metadata.aliases[1] | Should -Be "ls"
$result.Metadata.aliases[2] | Should -Be "gci"
}

It 'Should be able to read metata with alias as string' {
$result = Import-MarkdownCommandHelp -Path "$assetdir/Get-ChildItem-WithStringAliases.md"
$result.Metadata.aliases.Count | Should -Be 3
$result.Metadata.aliases[0] | Should -Be "dir"
$result.Metadata.aliases[1] | Should -Be "ls"
$result.Metadata.aliases[2] | Should -Be "gci"
}
}

Context "Validate Aliases" {
Expand Down
4 changes: 2 additions & 2 deletions test/Pester/MeasurePlatyPSMarkdown.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ Describe "Export-MarkdownModuleFile" {

It "Should identify all the '<fileType>' assets" -TestCases @(
@{ fileType = "unknown"; expectedCount = 2 }
@{ fileType = "CommandHelp"; expectedCount = 35 }
@{ fileType = "CommandHelp"; expectedCount = 37 }
@{ fileType = "ModuleFile"; expectedCount = 14 }
@{ fileType = "V1Schema"; expectedCount = 45 }
@{ fileType = "V1Schema"; expectedCount = 47 }
@{ fileType = "V2Schema"; expectedCount = 4 }
) {
param ($fileType, $expectedCount)
Expand Down
Loading