Skip to content

Commit f7132d9

Browse files
committed
Remove PR link from ToC header
1 parent f9d9150 commit f7132d9

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

make_release/notes/tools.nu

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,9 @@ export def write-toc [file: path] {
153153
| each {|header|
154154
let indent = '- ' | fill -w ($header.level * 2) -a right
155155

156-
let text = $header.line | str trim -l -c '#' | str trim -l
157-
let text = if $text ends-with $toc {
158-
$text | str substring ..<(-1 * ($toc | str length)) | str trim -r
159-
} else {
160-
$text
156+
mut text = $header.line | str trim -l -c '#' | str trim -l
157+
if $text ends-with $toc {
158+
$text = $text | str substring ..<(-1 * ($toc | str length)) | str trim -r
161159
}
162160

163161
let link = (
@@ -166,6 +164,22 @@ export def write-toc [file: path] {
166164
| str kebab-case
167165
)
168166

167+
# remove PR link from header, if applicable
168+
let regex = r#'(?x) # verbose mode
169+
(?<text>.+?) # the actual header text
170+
\s+
171+
\( # start PR link
172+
\[\#\d+\] # PR number component
173+
(?: # optional non-capturing group
174+
\(.+?\) # link to PR
175+
)? # end group
176+
\)
177+
'#
178+
let prlink = $text | parse -r $regex
179+
if ($prlink | is-not-empty) {
180+
$text = $prlink.0.text
181+
}
182+
169183
$"($indent)[_($text)_]\(#($link)-toc\)"
170184
}
171185
)

0 commit comments

Comments
 (0)