diff --git a/build/Publish-Module.ps1 b/build/Publish-Module.ps1 index 4ddcfe3..cce9d76 100644 --- a/build/Publish-Module.ps1 +++ b/build/Publish-Module.ps1 @@ -77,8 +77,11 @@ if (-not $match.Success -or -not $match.Groups['notes'].Value.Trim()) { $notes = ($match.Groups['notes'].Value -replace '(?m)^\[[^\]]+\]:\s*\S+\s*$', '').Trim() # the built manifest carries the notes (the gallery shows them); the source keeps its link. -# Update-ModuleManifest writes them safely (quotes, several lines) and can run again. -Update-ModuleManifest -Path $manifestPath -ReleaseNotes $notes +# Update-ModuleManifest writes them safely (quotes, several lines) and can run again. It doubles ' in +# its single-quoted string but not the typographic single quotes U+2018 to U+201B, which PowerShell +# reads as quotes too; doubled, each stays one character. +$manifestNotes = $notes -replace '([\u2018\u2019\u201A\u201B])', '$1$1' +Update-ModuleManifest -Path $manifestPath -ReleaseNotes $manifestNotes # the GitHub release takes the same text and names where the module is installed from $releaseNotes = "{0}`n`nIn the PowerShell Gallery: {1}" -f $notes, ($galleryPackageUrl -f $Module, $Version) Set-Content -LiteralPath (Join-Path $OutputPath "$Module-$Version.notes.md") -Value $releaseNotes -Encoding utf8NoBOM diff --git a/tests/powershell/Publish-Module.Tests.ps1 b/tests/powershell/Publish-Module.Tests.ps1 index 2dcf122..76ec7cc 100644 --- a/tests/powershell/Publish-Module.Tests.ps1 +++ b/tests/powershell/Publish-Module.Tests.ps1 @@ -68,4 +68,17 @@ Describe 'Publish-Module.ps1 release notes' { } finally { Remove-Item -LiteralPath $root -Recurse -Force } } + It 'keeps typographic single quotes, which PowerShell also reads as quotes' { + $q = [char]0x2019 + $root = Initialize-ReleaseFixture "## [1.2.3]`n`n- A folder of ``O${q}Neil`` and ${q}quoted${q}.`n" + try { + $script = Join-Path $root 'build' 'Publish-Module.ps1' + & $script -Module Demo.Module -Version 1.2.3 6>$null | Out-Null + & $script -Module Demo.Module -Version 1.2.3 6>$null | Out-Null + $notes = (Import-PowerShellDataFile (Join-Path $root 'output' 'Demo.Module' '1.2.3' 'Demo.Module.psd1')).PrivateData.PSData.ReleaseNotes + $notes | Should -BeExactly "- A folder of ``O${q}Neil`` and ${q}quoted${q}." + (Get-Content (Join-Path $root 'output' 'Demo.Module-1.2.3.notes.md') -Raw) | Should -BeLike "*O${q}Neil*" + } + finally { Remove-Item -LiteralPath $root -Recurse -Force } + } }