summaryrefslogtreecommitdiffstats
path: root/markup
diff options
context:
space:
mode:
authorJoe Mooring <joe.mooring@veriphor.com>2020-07-04 17:02:00 -0400
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2020-07-05 14:13:02 +0200
commit58c0f5e6171cbf8e3ed8d73ac95a7b85168c5b2f (patch)
treebb849d03ded34d1a413ca55140f119ddef5ee3aa /markup
parenta1c3e3c1f32bcbc3b3aa6921bdee98a9f795a2da (diff)
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
Diffstat (limited to 'markup')
-rw-r--r--markup/goldmark/autoid.go2
-rw-r--r--markup/goldmark/autoid_test.go3
2 files changed, 5 insertions, 0 deletions
diff --git a/markup/goldmark/autoid.go b/markup/goldmark/autoid.go
index 72cb79f71..1ca1ba5e0 100644
--- a/markup/goldmark/autoid.go
+++ b/markup/goldmark/autoid.go
@@ -54,6 +54,8 @@ func sanitizeAnchorNameWithHook(b []byte, idType string, hook func(buf *bytes.Bu
b = text.RemoveAccents(b)
}
+ b = bytes.TrimSpace(b)
+
for len(b) > 0 {
r, size := utf8.DecodeRune(b)
switch {
diff --git a/markup/goldmark/autoid_test.go b/markup/goldmark/autoid_test.go
index 0ddf5e886..7acae9f47 100644
--- a/markup/goldmark/autoid_test.go
+++ b/markup/goldmark/autoid_test.go
@@ -66,6 +66,9 @@ tabspace
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")
}