Skip to content

Commit

Permalink
Merge pull request #72 from StartAutomating/Format-Markdown-Fix
Browse files Browse the repository at this point in the history
Format-Markdown-Fix
  • Loading branch information
StartAutomating authored Sep 15, 2022
2 parents b30a461 + d8aec4c commit 86f30db
Show file tree
Hide file tree
Showing 38 changed files with 121 additions and 93 deletions.
18 changes: 15 additions & 3 deletions .github/workflows/TestReleaseAndPublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -422,19 +422,30 @@ jobs:
$ModulePath,
[string[]]
$Exclude = @('*.png', '*.mp4', '*.jpg','*.jpeg')
$Exclude = @('*.png', '*.mp4', '*.jpg','*.jpeg', '*.gif', 'docs[/\]*')
)
$gitHubEvent = if ($env:GITHUB_EVENT_PATH) {
[IO.File]::ReadAllText($env:GITHUB_EVENT_PATH) | ConvertFrom-Json
} else { $null }
if (-not $Exclude) {
$Exclude = @('*.png', '*.mp4', '*.jpg','*.jpeg', '*.gif','docs[/\]*')
}
@"
::group::GitHubEvent
$($gitHubEvent | ConvertTo-Json -Depth 100)
::endgroup::
"@ | Out-Host
@"
::group::PSBoundParameters
$($PSBoundParameters | ConvertTo-Json -Depth 100)
::endgroup::
"@ | Out-Host
if (-not ($gitHubEvent.head_commit.message -match "Merge Pull Request #(?<PRNumber>\d+)") -and
(-not $gitHubEvent.psobject.properties['inputs'])) {
"::warning::Pull Request has not merged, skipping Gallery Publish" | Out-Host
Expand Down Expand Up @@ -479,11 +490,12 @@ jobs:
}
if ($Exclude) {
"::notice::Attempting to Exlcude $exclude" | Out-Host
Get-ChildItem $moduleTempPath -Recurse |
Where-Object {
Where-Object {
foreach ($ex in $exclude) {
if ($_.FullName -like $ex) {
"::notice::Excluding $($_.FullName)"
"::notice::Excluding $($_.FullName)" | Out-Host
return $true
}
}
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 1.9.2:
* Format-Markdown:
* Improving Handling of | (Fixes #71)
* Not escaping code blocks (undoes #69)
* No longer including images with PowerShell Gallery package (Fixes #67)
---

## 1.9.1:
* Format-Markdown: Escaping -Code blocks (Fixes #69)
---
Expand Down
14 changes: 7 additions & 7 deletions EZOut.format.ps1xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-16"?>
<!-- Generated with EZOut 1.9.1: Install-Module EZOut or https://github.com/StartAutomating/EZOut -->
<!-- Generated with EZOut 1.9.2: Install-Module EZOut or https://github.com/StartAutomating/EZOut -->
<Configuration>
<SelectionSets>
<SelectionSet>
Expand Down Expand Up @@ -1436,7 +1436,7 @@ if ($Request -or $Host.UI.SupportsHTML) {
[Environment]::newline + # then a newline,
$(
$codeContent = $(if ($ScriptBlock) { "$scriptBlock" } else { $inputObject | LinkInput}) # then the -ScriptBlock or -InputObject
[Web.HttpUtility]::HtmlEncode($codeContent)
$codeContent
) +
[Environment]::newline + # then a newline
'```' # then close the code fence.
Expand Down Expand Up @@ -1544,7 +1544,7 @@ if ($Request -or $Host.UI.SupportsHTML) {
} else {
$prop.Name
}
}) -replace ([Environment]::newline), '&lt;br/&gt;' -replace '\|', '`|' -join '|') + '|'
}) -replace ([Environment]::newline), '&lt;br/&gt;' -replace '\|', '\|' -join '|') + '|'
# Then create the alignment row.
$markdownLines +=
'|' + $(
Expand Down Expand Up @@ -1575,7 +1575,7 @@ if ($Request -or $Host.UI.SupportsHTML) {

$columnNumber++
}
) -replace ([Environment]::newline), '&lt;br/&gt;' -replace '\|', '`|' -join '|') + '|'
) -replace ([Environment]::newline), '&lt;br/&gt;' -replace '\|', '\|' -join '|') + '|'
$IsFirst = $false
}

Expand All @@ -1590,7 +1590,7 @@ if ($Request -or $Host.UI.SupportsHTML) {
$prop.Value | LinkInput
}
}
) -replace ([Environment]::newline), '&lt;br/&gt;' -replace '\|', '`|' -join '|') + '|'
) -replace ([Environment]::newline), '&lt;br/&gt;' -replace '\|', '\|' -join '|') + '|'

$markdownLines += $markdownLine
}
Expand Down Expand Up @@ -1623,7 +1623,7 @@ if ($Request -or $Host.UI.SupportsHTML) {
foreach ($ml in $markdownLines) {
if ($ml -match '\^|') {
$columnCount = 0
foreach ($tablePart in $ml -split '\|' -ne '') {
foreach ($tablePart in $ml -split '(?&lt;!\\)\|' -ne '') {
if ((-not $maxColumnSize[$columnCount]) -or $maxColumnSize[$columnCount] -lt $tablePart.Length) {
$maxColumnSize[$columnCount] = [Math]::Max($tablePart.Length, 2)
}
Expand All @@ -1636,7 +1636,7 @@ if ($Request -or $Host.UI.SupportsHTML) {
if ($ml -match '\^|') {
$columnCount = 0
# Recreate the line with the right amount of padding.
'|' + (@(foreach ($tablePart in $ml -split '\|' -ne '') {
'|' + (@(foreach ($tablePart in $ml -split '(?&lt;!\\)\|' -ne '') {
if ($tablePart -match '^[:\-]+$') {
if ($tablePart -match '^\:-{0,}\:$') { # If it's an alignment column, make sure to keep the alignment.
if ($maxColumnSize[$columnCount] -gt 2) {
Expand Down
8 changes: 7 additions & 1 deletion EZOut.psd1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@{
ModuleToProcess = 'EZOut.psm1'
ModuleVersion = '1.9.1'
ModuleVersion = '1.9.2'
GUID = 'cef786f0-8a0b-4a5d-a2c6-b433095354cd'
Author = 'James Brundage'
CompanyName = 'Start-Automating'
Expand Down Expand Up @@ -43,6 +43,12 @@

Tags = '.ps1xml', 'Format','Output','Types', 'Colorized'
ReleaseNotes = @'
## 1.9.2:
* Format-Markdown:
* Improving Handling of | (Fixes #71)
* Not escaping code blocks (undoes #69)
* No longer including images with PowerShell Gallery package (Fixes #67)
---
## 1.9.1:
* Format-Markdown: Escaping -Code blocks (Fixes #69)
---
Expand Down
6 changes: 1 addition & 5 deletions EZOut.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1174,11 +1174,7 @@ describe 'Format-Markdown' {
$formatMarkdown = @{a='b'} | Format-Markdown
$formatMarkdown | Should -belike '*|a*'
$formatMarkdown | Should -belike '*|b*'
}

it 'Will escape code within -Code blocks' {
{ =<svg> } | Format-Markdown | Should -BeLike '*&lt;svg&gt;*'
}
}
}

describe 'Format-Hashtable' {
Expand Down
12 changes: 6 additions & 6 deletions Format-Markdown.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ function Format-Markdown
[Environment]::newline + # then a newline,
$(
$codeContent = $(if ($ScriptBlock) { "$scriptBlock" } else { $inputObject | LinkInput}) # then the -ScriptBlock or -InputObject
[Web.HttpUtility]::HtmlEncode($codeContent)
$codeContent
) +
[Environment]::newline + # then a newline
'```' # then close the code fence.
Expand Down Expand Up @@ -291,7 +291,7 @@ function Format-Markdown
} else {
$prop.Name
}
}) -replace ([Environment]::newline), '<br/>' -replace '\|', '`|' -join '|') + '|'
}) -replace ([Environment]::newline), '<br/>' -replace '\|', '\|' -join '|') + '|'
# Then create the alignment row.
$markdownLines +=
'|' + $(
Expand Down Expand Up @@ -322,7 +322,7 @@ function Format-Markdown

$columnNumber++
}
) -replace ([Environment]::newline), '<br/>' -replace '\|', '`|' -join '|') + '|'
) -replace ([Environment]::newline), '<br/>' -replace '\|', '\|' -join '|') + '|'
$IsFirst = $false
}

Expand All @@ -337,7 +337,7 @@ function Format-Markdown
$prop.Value | LinkInput
}
}
) -replace ([Environment]::newline), '<br/>' -replace '\|', '`|' -join '|') + '|'
) -replace ([Environment]::newline), '<br/>' -replace '\|', '\|' -join '|') + '|'

$markdownLines += $markdownLine
}
Expand Down Expand Up @@ -370,7 +370,7 @@ function Format-Markdown
foreach ($ml in $markdownLines) {
if ($ml -match '\^|') {
$columnCount = 0
foreach ($tablePart in $ml -split '\|' -ne '') {
foreach ($tablePart in $ml -split '(?<!\\)\|' -ne '') {
if ((-not $maxColumnSize[$columnCount]) -or $maxColumnSize[$columnCount] -lt $tablePart.Length) {
$maxColumnSize[$columnCount] = [Math]::Max($tablePart.Length, 2)
}
Expand All @@ -383,7 +383,7 @@ function Format-Markdown
if ($ml -match '\^|') {
$columnCount = 0
# Recreate the line with the right amount of padding.
'|' + (@(foreach ($tablePart in $ml -split '\|' -ne '') {
'|' + (@(foreach ($tablePart in $ml -split '(?<!\\)\|' -ne '') {
if ($tablePart -match '^[:\-]+$') {
if ($tablePart -match '^\:-{0,}\:$') { # If it's an alignment column, make sure to keep the alignment.
if ($maxColumnSize[$columnCount] -gt 2) {
Expand Down
6 changes: 3 additions & 3 deletions docs/Add-FormatData.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ temporary module to use the formatting file.
### Examples
#### EXAMPLE 1
```PowerShell
# Let's start off by looking at how something like XML is rendered in PowerShell
[xml]"<a an='anattribute'><b d='attribute'><c/></b></a>"
# Let&#39;s start off by looking at how something like XML is rendered in PowerShell
[xml]&quot;&lt;a an=&#39;anattribute&#39;&gt;&lt;b d=&#39;attribute&#39;&gt;&lt;c/&gt;&lt;/b&gt;&lt;/a&gt;&quot;
```
# It's not very intuitive.
# I cannot really only see the element I am looking at, instead of a chunk of data
Expand Down Expand Up @@ -126,7 +126,7 @@ System.Management.Automation.PSModuleInfo
---
### Syntax
```PowerShell
Add-FormatData [-FormatXml] <XmlDocument> [[-Name] <String>] [-PassThru] [<CommonParameters>]
Add-FormatData [-FormatXml] &lt;XmlDocument&gt; [[-Name] &lt;String&gt;] [-PassThru] [&lt;CommonParameters&gt;]
```
---

Expand Down
2 changes: 1 addition & 1 deletion docs/Add-TypeData.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ System.Management.Automation.PSModuleInfo
---
### Syntax
```PowerShell
Add-TypeData [-TypeXml] <XmlDocument> [[-Name] <String>] [-PassThru] [<CommonParameters>]
Add-TypeData [-TypeXml] &lt;XmlDocument&gt; [[-Name] &lt;String&gt;] [-PassThru] [&lt;CommonParameters&gt;]
```
---

Expand Down
7 changes: 7 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 1.9.2:
* Format-Markdown:
* Improving Handling of | (Fixes #71)
* Not escaping code blocks (undoes #69)
* No longer including images with PowerShell Gallery package (Fixes #67)
---

## 1.9.1:
* Format-Markdown: Escaping -Code blocks (Fixes #69)
---
Expand Down
2 changes: 1 addition & 1 deletion docs/Clear-FormatData.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ System.Nullable
---
### Syntax
```PowerShell
Clear-FormatData [<CommonParameters>]
Clear-FormatData [&lt;CommonParameters&gt;]
```
---

Expand Down
2 changes: 1 addition & 1 deletion docs/Clear-TypeData.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ The formatting data must have been added with Add-FormatData
---
### Syntax
```PowerShell
Clear-TypeData [<CommonParameters>]
Clear-TypeData [&lt;CommonParameters&gt;]
```
---

Expand Down
2 changes: 1 addition & 1 deletion docs/ConvertTo-PropertySet.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ System.String
---
### Syntax
```PowerShell
ConvertTo-PropertySet -SelectedObject <Object> [-Name] <Object> [<CommonParameters>]
ConvertTo-PropertySet -SelectedObject &lt;Object&gt; [-Name] &lt;Object&gt; [&lt;CommonParameters&gt;]
```
---

Expand Down
2 changes: 1 addition & 1 deletion docs/Find-FormatView.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ The name of the type of format view to find
---
### Syntax
```PowerShell
Find-FormatView [-TypeName] <String> [<CommonParameters>]
Find-FormatView [-TypeName] &lt;String&gt; [&lt;CommonParameters&gt;]
```
---

Expand Down
4 changes: 2 additions & 2 deletions docs/Format-Hashtable.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Handles nested hashtables and indents nested hashtables automatically.
#### EXAMPLE 1
```PowerShell
# Corrects the presentation of a PowerShell hashtable
[Ordered]@{Foo='Bar';Baz='Bing';Boo=@{Bam='Blang'}} | Format-Hashtable
[Ordered]@{Foo=&#39;Bar&#39;;Baz=&#39;Bing&#39;;Boo=@{Bam=&#39;Blang&#39;}} | Format-Hashtable
```

---
Expand Down Expand Up @@ -175,7 +175,7 @@ Beneath this depth, items will simply be returned as $null.
---
### Syntax
```PowerShell
Format-Hashtable [[-InputObject] <PSObject>] [-AsScriptBlock] [-AsPSObject] [-Sort] [-ExpandCredential] [-Compress] [-Safe] [-Depth <Int32>] [<CommonParameters>]
Format-Hashtable [[-InputObject] &lt;PSObject&gt;] [-AsScriptBlock] [-AsPSObject] [-Sort] [-ExpandCredential] [-Compress] [-Safe] [-Depth &lt;Int32&gt;] [&lt;CommonParameters&gt;]
```
---

Expand Down
2 changes: 1 addition & 1 deletion docs/Format-Heatmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ To pass a Hex color as an int, simply replace # with 0x
---
### Syntax
```PowerShell
Format-Heatmap [[-InputObject] <Object>] [-HeatMapMax] <Object> [[-HeatMapMiddle] <Object>] [[-HeatMapMin] <Object>] [[-HeatMapCool] <Int32>] [[-HeatMapHot] <Int32>] [<CommonParameters>]
Format-Heatmap [[-InputObject] &lt;Object&gt;] [-HeatMapMax] &lt;Object&gt; [[-HeatMapMiddle] &lt;Object&gt;] [[-HeatMapMin] &lt;Object&gt;] [[-HeatMapCool] &lt;Int32&gt;] [[-HeatMapHot] &lt;Int32&gt;] [&lt;CommonParameters&gt;]
```
---

Expand Down
2 changes: 1 addition & 1 deletion docs/Format-Markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ If provided, will output a script block as a Markdown code block.
---
### Syntax
```PowerShell
Format-Markdown [[-InputObject] <PSObject>] [-MarkdownParagraph] [-MarkdownTable] [[-MarkdownTableAlignment] <String[]>] [[-Property] <PSObject[]>] [[-Heading] <String>] [[-HeadingSize] <Int32>] [[-Link] <String>] [[-ImageLink] <String>] [-BulletPoint] [-Checkbox] [-Checked] [-NumberedList] [-BlockQuote] [[-BlockQuoteDepth] <Int32>] [[-Number] <Int32>] [-HorizontalRule] [-Code] [[-CodeLanguage] <String>] [[-ScriptBlock] <ScriptBlock>] [<CommonParameters>]
Format-Markdown [[-InputObject] &lt;PSObject&gt;] [-MarkdownParagraph] [-MarkdownTable] [[-MarkdownTableAlignment] &lt;String[]&gt;] [[-Property] &lt;PSObject[]&gt;] [[-Heading] &lt;String&gt;] [[-HeadingSize] &lt;Int32&gt;] [[-Link] &lt;String&gt;] [[-ImageLink] &lt;String&gt;] [-BulletPoint] [-Checkbox] [-Checked] [-NumberedList] [-BlockQuote] [[-BlockQuoteDepth] &lt;Int32&gt;] [[-Number] &lt;Int32&gt;] [-HorizontalRule] [-Code] [[-CodeLanguage] &lt;String&gt;] [[-ScriptBlock] &lt;ScriptBlock&gt;] [&lt;CommonParameters&gt;]
```
---

Expand Down
4 changes: 2 additions & 2 deletions docs/Format-Object.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Formats any object, using any number of Format-Object extensions.
### Examples
#### EXAMPLE 1
```PowerShell
"red" | Format-Object -ForegroundColor "red"
&quot;red&quot; | Format-Object -ForegroundColor &quot;red&quot;
```

#### EXAMPLE 2
Expand All @@ -60,7 +60,7 @@ Formats any object, using any number of Format-Object extensions.
---
### Syntax
```PowerShell
Format-Object [[-InputObject] <PSObject>] [<CommonParameters>]
Format-Object [[-InputObject] &lt;PSObject&gt;] [&lt;CommonParameters&gt;]
```
---

Expand Down
2 changes: 1 addition & 1 deletion docs/Format-RichText.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ If set, will not clear formatting
---
### Syntax
```PowerShell
Format-RichText [[-InputObject] <PSObject>] [[-ForegroundColor] <String>] [[-BackgroundColor] <String>] [-Bold] [-Blink] [-Strikethru] [-Underline] [-Invert] [-NoClear] [<CommonParameters>]
Format-RichText [[-InputObject] &lt;PSObject&gt;] [[-ForegroundColor] &lt;String&gt;] [[-BackgroundColor] &lt;String&gt;] [-Bold] [-Blink] [-Strikethru] [-Underline] [-Invert] [-NoClear] [&lt;CommonParameters&gt;]
```
---
### Notes
Expand Down
6 changes: 3 additions & 3 deletions docs/Format-YAML.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ Formats an object as YAML.
### Examples
#### EXAMPLE 1
```PowerShell
Format-Yaml -InputObject @("a", "b", "c")
Format-Yaml -InputObject @(&quot;a&quot;, &quot;b&quot;, &quot;c&quot;)
```

#### EXAMPLE 2
```PowerShell
@{a="b";c="d";e=@{f=@('g')}} | Format-Yaml
@{a=&quot;b&quot;;c=&quot;d&quot;;e=@{f=@(&#39;g&#39;)}} | Format-Yaml
```

---
Expand Down Expand Up @@ -90,7 +90,7 @@ Beyond this depth, an empty string will be returned.
---
### Syntax
```PowerShell
Format-YAML [[-InputObject] <PSObject>] [-YamlHeader] [[-Indent] <Int32>] [[-Depth] <Int32>] [<CommonParameters>]
Format-YAML [[-InputObject] &lt;PSObject&gt;] [-YamlHeader] [[-Indent] &lt;Int32&gt;] [[-Depth] &lt;Int32&gt;] [&lt;CommonParameters&gt;]
```
---

Expand Down
2 changes: 1 addition & 1 deletion docs/Get-EZOutExtension.md
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ Extension
---
### Syntax
```PowerShell
Get-EZOutExtension [[-ExtensionPath] <String>] [-Force] [[-CommandName] <String[]>] [[-ExtensionName] <String[]>] [-Like] [-Match] [-DynamicParameter] [-CouldRun] [-Run] [-Stream] [[-DynamicParameterSetName] <String>] [[-DynamicParameterPositionOffset] <Int32>] [-NoMandatoryDynamicParameter] [[-ValidateInput] <PSObject>] [-AllValid] [[-ParameterSetName] <String>] [[-Parameter] <IDictionary>] [-SteppablePipeline] [-Help] [[-ParameterHelp] <String[]>] [-Example] [-FullHelp] [<CommonParameters>]
Get-EZOutExtension [[-ExtensionPath] &lt;String&gt;] [-Force] [[-CommandName] &lt;String[]&gt;] [[-ExtensionName] &lt;String[]&gt;] [-Like] [-Match] [-DynamicParameter] [-CouldRun] [-Run] [-Stream] [[-DynamicParameterSetName] &lt;String&gt;] [[-DynamicParameterPositionOffset] &lt;Int32&gt;] [-NoMandatoryDynamicParameter] [[-ValidateInput] &lt;PSObject&gt;] [-AllValid] [[-ParameterSetName] &lt;String&gt;] [[-Parameter] &lt;IDictionary&gt;] [-SteppablePipeline] [-Help] [[-ParameterHelp] &lt;String[]&gt;] [-Example] [-FullHelp] [&lt;CommonParameters&gt;]
```
---

Expand Down
2 changes: 1 addition & 1 deletion docs/Get-FormatFile.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Get-FormatFile -OnlyBuildIn
---
### Syntax
```PowerShell
Get-FormatFile [-OnlyFromModule] [-OnlyBuiltIn] [-FromSnapins] [<CommonParameters>]
Get-FormatFile [-OnlyFromModule] [-OnlyBuiltIn] [-FromSnapins] [&lt;CommonParameters&gt;]
```
---

Expand Down
2 changes: 1 addition & 1 deletion docs/Get-PropertySet.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ System.Management.Automation.PSObject
---
### Syntax
```PowerShell
Get-PropertySet [[-TypeName] <String[]>] [<CommonParameters>]
Get-PropertySet [[-TypeName] &lt;String[]&gt;] [&lt;CommonParameters&gt;]
```
---

Expand Down
Loading

0 comments on commit 86f30db

Please sign in to comment.