From 5a3b50faa04bfc96c773a4d59f74dd3a3e994738 Mon Sep 17 00:00:00 2001 From: Manjunath Beli <61643561+belibug@users.noreply.github.com> Date: Thu, 6 Jun 2024 10:58:47 -0300 Subject: [PATCH] Updated MDAlert to begin-process block to match module style Removed non-functional changes mentioned in CHANGELOG --- CHANGELOG.md | 3 +-- Src/Modules/MarkdownPS/Public/New-MDAlert.ps1 | 17 ++++++++--------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eaa9404..8d0e5b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,6 @@ -**v1.10** *20240605* +**v1.10** *In progress* - Fixed issue with GH-33 where the `New-MDQuote` would output extra `> ` between quote lines - GH-28 Added new command `New-MDAlert` for GFM Alerts - thanks to @belibug -- Updated tests from Pester v4 to v5 **v1.9** *20200227* - Based on GH-20 the default output of `New-MDTable` has a cell length alignment per column. New parameter `-Shrink` is added to reduce the overall size and each cell is not padded. Thanks to @al-cheb diff --git a/Src/Modules/MarkdownPS/Public/New-MDAlert.ps1 b/Src/Modules/MarkdownPS/Public/New-MDAlert.ps1 index 788dc2e..5dbb451 100644 --- a/Src/Modules/MarkdownPS/Public/New-MDAlert.ps1 +++ b/Src/Modules/MarkdownPS/Public/New-MDAlert.ps1 @@ -39,9 +39,9 @@ .EXAMPLE @("Line 1","Line 2") | New-MDAlert -Style Caution - >> [!CAUTION] - >> Line 1 - >> Line 2 + > [!CAUTION] + > Line 1 + > Line 2 .LINK Refer "https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#alerts" for more details. @@ -77,19 +77,18 @@ function New-MDAlert { Begin { $output = '' - $admonition = '[!{0}]' -f $Style.ToUpper() - $output += New-MDQuote -Lines $admonition -Level 1 -NoNewLine + $newLine = [System.Environment]::NewLine } Process { - $lines | ForEach-Object { - $output += New-MDQuote -Lines $_ -Level 1 -NoNewLine - } + $output += New-MDQuote -Lines $Lines -Level 1 -NoNewLine } End { + $admonition = '> [!{0}]' -f $Style.ToUpper() + $output = $admonition + $newLine +$output if (-not $NoNewLine) { - $output += [System.Environment]::NewLine + $output += $newLine } $output }