Skip to content

Commit e09c469

Browse files
author
Kapil Borle
committed
Add function to remove hyperlinks from markdown
The ReleaseMaker module extracts changelog for a given version from changelog.md and sets it 'ReleaseNotes' value in the module manifest. When we publish the module to powershellgallery.com, the release notes are displayed on the module page which cannot render the markdown links. Hence we need to remove them when plugging the changelog into release notes.
1 parent 5acd742 commit e09c469

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

Utils/ReleaseMaker.psm1

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,15 @@ function Update-ReleaseNotesInModuleManifest
118118
-f [regex]::Escape($newVer),[regex]::Escape($oldVer)
119119
$changelogRegex = [regex]::new($changelogRegexPattern)
120120
$matches = $changelogRegex.Match((get-content $changelogPath -raw))
121-
$changelog = $matches.Groups[1].Value.Trim()
121+
$changelogWithHyperlinks = $matches.Groups[1].Value.Trim()
122122

123-
Write-Verbose 'CHANGELOG'
123+
Write-Verbose 'CHANGELOG:'
124+
Write-Verbose $changelogWithHyperlinks
125+
126+
# Remove hyperlinks from changelog to make is suitable for publishing on powershellgallery.com
127+
Write-Verbose "Removing hyperlinks from changelog"
128+
$changelog = Remove-MarkdownHyperlink $changelogWithHyperlinks
129+
Write-Verbose "CHANGELOG without hyperlinks:"
124130
Write-Verbose $changelog
125131

126132
$releaseNotesPattern = `
@@ -135,11 +141,17 @@ function Update-ReleaseNotesInModuleManifest
135141
Set-ContentUtf8NoBom $moduleManifestPath $updatedManifestContent
136142
}
137143

144+
function Remove-MarkdownHyperlink
145+
{
146+
param($markdownContent)
147+
$markdownContent -replace "\[(.*)\]\(.*\)",'$1'
148+
}
149+
138150
function Combine-Path
139151
{
140152
if ($args.Count -lt 2)
141153
{
142-
throw "give more than equal to 2 arguments"
154+
throw "give more 1 argument"
143155
}
144156

145157
$path = Join-Path $args[0] $args[1]

0 commit comments

Comments
 (0)