From 1fd25e0aebcbaf1d03d4499245ee24167500abb6 Mon Sep 17 00:00:00 2001 From: Robert Toups Date: Fri, 15 Jan 2021 23:13:44 -0500 Subject: [PATCH] Improve Example output formatting The current formatting does not tag the code block as PowerShell. The remarks attribute sometimes is the formatted output of the example which are not within the code block. If there is a new line between the command example and the output of the command in the ".EXAMPLE", the output is considered remarks and will be unformatted by the current implementation. This provides, subjectively, a more esthetic output. Here is an example of the output: https://github.com/roberttoups/IPv4Toolbox/blob/master/IPv4Toolbox/0.1.0/Docs/Invoke-IPv4ListSort.md --- src/platyPS/platyPS.psm1 | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/platyPS/platyPS.psm1 b/src/platyPS/platyPS.psm1 index 763023db..ab85aed6 100644 --- a/src/platyPS/platyPS.psm1 +++ b/src/platyPS/platyPS.psm1 @@ -2865,15 +2865,17 @@ function ConvertPsObjectsToMamlModel $MamlExampleObject.Introduction = $Example.introduction $MamlExampleObject.Title = $Example.title + + $CodeBlock = @" +$($Example.code.Trim()) + +$($Example.remarks.text.Trim()) +"@ + $CodeBlock = $CodeBlock.Trim() $MamlExampleObject.Code = @( - New-Object -TypeName Markdown.MAML.Model.MAML.MamlCodeBlock ($Example.code, '') + New-Object -TypeName Markdown.MAML.Model.MAML.MamlCodeBlock($CodeBlock, 'powershell') ) - $RemarkText = $Example.remarks | - DescriptionToPara | - AddLineBreaksForParagraphs - - $MamlExampleObject.Remarks = $RemarkText $MamlCommandObject.Examples.Add($MamlExampleObject) }