ref: 58c0f5e6171cbf8e3ed8d73ac95a7b85168c5b2f
parent: a1c3e3c1f32bcbc3b3aa6921bdee98a9f795a2da
author: Joe Mooring <joe.mooring@veriphor.com>
date: Sat Jul 4 13:02:00 EDT 2020
Remove trailing hyphen from auto heading ID Applicable when autoHeadingIDType is either `github` or `github-ascii`. When autoHeadingIDType is `blackfriday`, the existing code removes trailing whitespace while iterating through the characters, using a boolean "futureDash" mechanism. Fixes #6798
--- a/markup/goldmark/autoid.go
+++ b/markup/goldmark/autoid.go
@@ -54,6 +54,8 @@
b = text.RemoveAccents(b)
}
+ b = bytes.TrimSpace(b)
+
for len(b) > 0 {
r, size := utf8.DecodeRune(b)
switch {
--- a/markup/goldmark/autoid_test.go
+++ b/markup/goldmark/autoid_test.go
@@ -66,6 +66,9 @@
testlines, expectlines := strings.Split(tests, "\n"), strings.Split(expect, "\n")
+ testlines = append(testlines, "Trailing Space ")
+ expectlines = append(expectlines, "trailing-space")
+
if len(testlines) != len(expectlines) {
panic("test setup failed")
}