diff --git a/src/Command/ExportMamlCommandHelp.cs b/src/Command/ExportMamlCommandHelp.cs
index 3f8e8519..a164c778 100644
--- a/src/Command/ExportMamlCommandHelp.cs
+++ b/src/Command/ExportMamlCommandHelp.cs
@@ -96,7 +96,15 @@ protected override void EndProcessing()
}
else
{
- WriteObject(this.InvokeProvider.Item.Get(MamlConversionHelper.WriteToFile(helpInfos, moduleMamlPath, Encoding).FullName));
+ var mamlFile = MamlConversionHelper.WriteToFile(helpInfos, moduleMamlPath, Encoding);
+
+ // Read the MAML file and replace the specific line
+ string mamlContent = File.ReadAllText(mamlFile.FullName, Encoding);
+ // Replace the line break placeholder with a proper line break
+ // This is a workaround for the issue where line breaks are not preserved in MAML files
+ string updatedContent = mamlContent.Replace("__REMOVE_ME_LINE_BREAK__", " ");
+ File.WriteAllText(mamlFile.FullName, updatedContent, Encoding);
+ WriteObject(this.InvokeProvider.Item.Get(mamlFile.FullName));
}
}
}
diff --git a/src/MamlWriter/MamlHelpers.cs b/src/MamlWriter/MamlHelpers.cs
index 0c53c2d7..d1c49984 100644
--- a/src/MamlWriter/MamlHelpers.cs
+++ b/src/MamlWriter/MamlHelpers.cs
@@ -194,12 +194,25 @@ private static Parameter ConvertParameter(Model.Parameter parameter)
private static CommandExample ConvertExample(Example example, int exampleNumber)
{
+ var tempDescription = new List();
var newExample = new CommandExample();
newExample.Title = string.Format($"--------- {example.Title} ---------");
foreach(string s in example.Remarks.Split(new string[] { "\n\n" }, StringSplitOptions.None))
{
- newExample.Description.Add(s.Trim());
+ tempDescription.Add(s.Trim());
}
+
+ for (int i = 0; i < tempDescription.Count; i++)
+ {
+ newExample.Description.Add(tempDescription[i]);
+
+ // Add an empty line after each item except the last
+ if (i < tempDescription.Count - 1)
+ {
+ newExample.Description.Add("__REMOVE_ME_LINE_BREAK__"); // Non-breaking space for empty line
+ }
+ }
+
return newExample;
}
diff --git a/test/Pester/ExportMamlCommandHelp.Tests.ps1 b/test/Pester/ExportMamlCommandHelp.Tests.ps1
index 51ee49fa..34b6db33 100644
--- a/test/Pester/ExportMamlCommandHelp.Tests.ps1
+++ b/test/Pester/ExportMamlCommandHelp.Tests.ps1
@@ -129,5 +129,11 @@ Describe "Export-MamlCommandHelp tests" {
$observed = $xml2.SelectNodes('//command:command', $ns2).Where({$_.details.name -eq "Get-Date"}).examples.example.title
$observed | Should -Be $expected
}
+
+ It "Should have the line break workaround in the example code" {
+ $m = Import-MarkdownCommandHelp -Path (Join-Path $assetDir 'get-date.md')
+ $mamlFie = $m | Export-MamlCommandHelp -OutputFolder $outputDirectory -Force
+ $mamlFie | Should -FileContentMatch ' '
+ }
}
}