Skip to content

Commit 4e9d2af

Browse files
Merge pull request #176 from ShaunLawrie/master
Fix #175
2 parents 75e579f + e2587c2 commit 4e9d2af

File tree

4 files changed

+27
-12
lines changed

4 files changed

+27
-12
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
### HelpOut 0.5.3:
2+
3+
* Save-MarkdownHelp:
4+
* Fix saving markdown with Windows paths ( #175 )
5+
6+
Thanks @ShaunLawrie !
7+
8+
---
9+
110
### HelpOut 0.5.2:
211

312
* Save-MarkdownHelp:

HelpOut.psd1

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,20 @@
77
ModuleToProcess='HelpOut.psm1'
88
FormatsToProcess='HelpOut.format.ps1xml'
99
TypesToProcess='HelpOut.types.ps1xml'
10-
ModuleVersion='0.5.2'
10+
ModuleVersion='0.5.3'
1111
PrivateData = @{
1212
PSData = @{
1313
ProjectURI = 'https://github.com/StartAutomating/HelpOut'
1414
LicenseURI = 'https://github.com/StartAutomating/HelpOut/blob/master/LICENSE'
1515

1616
Tags = 'Markdown', 'Help','PowerShell'
1717
ReleaseNotes = @'
18-
### HelpOut 0.5.2:
18+
### HelpOut 0.5.3:
1919
2020
* Save-MarkdownHelp:
21-
* IncludeSubModule/-ExcludeSubModule ( #155 )
22-
* -IncludePath ( #169 )
23-
* -ExcludeFile aliases ( #168 )
24-
* -ExcludeExtension ( #167 )
25-
* Not Saving Files with colons ( #163 )
21+
* Fix saving markdown with Windows paths ( #175 )
2622
27-
Thanks @PrzemyslawKlys !
23+
Thanks @ShaunLawrie !
2824
2925
---
3026

HelpOut.types.ps1xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,13 @@ $FilePath,
6161
$View = 'PowerShell.Markdown.Help'
6262
)
6363

64-
if ($filePath -match '[\<\>\|\?\*\:]') {
65-
Write-Warning "Will not .Save to $filePath, because that path will not be readable on all operating systems."
64+
$illegalCharacters = @('<', '>', '|', '?', '*', ':')
65+
$illegalCharacterRegex = '[' + ($illegalCharacters | Foreach-Object { [regex]::Escape($_) }) + ']'
66+
$illegalCharacterReadable = ($illegalCharacters | Foreach-Object { "`"$_`"" }) -join ', '
67+
68+
$filePathWithoutQualifier = Split-Path $filePath -NoQualifier
69+
if ($filePathWithoutQualifier -match $illegalCharacterRegex) {
70+
Write-Warning "Will not .Save to $filePath, because that path will not be readable on all operating systems. It cannot contain any of the characters $illegalCharacterReadable."
6671
return
6772
}
6873

Types/PowerShell.Markdown.Help/Save.ps1

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,13 @@ $FilePath,
2222
$View = 'PowerShell.Markdown.Help'
2323
)
2424

25-
if ($filePath -match '[\<\>\|\?\*\:]') {
26-
Write-Warning "Will not .Save to $filePath, because that path will not be readable on all operating systems."
25+
$illegalCharacters = @('<', '>', '|', '?', '*', ':')
26+
$illegalCharacterRegex = '[' + ($illegalCharacters | Foreach-Object { [regex]::Escape($_) }) + ']'
27+
$illegalCharacterReadable = ($illegalCharacters | Foreach-Object { "`"$_`"" }) -join ', '
28+
29+
$filePathWithoutQualifier = Split-Path $filePath -NoQualifier
30+
if ($filePathWithoutQualifier -match $illegalCharacterRegex) {
31+
Write-Warning "Will not .Save to $filePath, because that path will not be readable on all operating systems. It cannot contain any of the characters $illegalCharacterReadable."
2732
return
2833
}
2934

0 commit comments

Comments
 (0)