shithub: hugo

Download patch

ref: 9b6e61464b09ffe3423fb8d7c72bddb7a9ed5b98
parent: d62ede8e9e5883e7ebb023e49b82f07b45edc1c7
author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
date: Sun Jan 5 10:58:14 EST 2020

markup/goldmark: Adjust auto ID space handling

GitHub does not consider tabs as delimiter, see https://github.com/bep/portable-hugo-links/blob/master/blog/p2.md

Closes #6710

--- a/markup/goldmark/autoid.go
+++ b/markup/goldmark/autoid.go
@@ -58,7 +58,7 @@
 			r, size := utf8.DecodeRune(b)
 			switch {
 			case asciiOnly && size != 1:
-			case r == '-' || isSpace(r):
+			case r == '-' || r == ' ':
 				buf.WriteRune('-')
 			case isAlphaNumeric(r):
 				buf.WriteRune(unicode.ToLower(r))
@@ -83,10 +83,6 @@
 
 func isAlphaNumeric(r rune) bool {
 	return r == '_' || unicode.IsLetter(r) || unicode.IsDigit(r)
-}
-
-func isSpace(r rune) bool {
-	return r == ' ' || r == '\t'
 }
 
 var _ parser.IDs = (*idFactory)(nil)
--- a/markup/goldmark/autoid_test.go
+++ b/markup/goldmark/autoid_test.go
@@ -40,6 +40,8 @@
 Forward/slash
 Backward\slash
 Under_score
+Nonbreaking Space
+Tab	Space
 `
 
 	expect := `
@@ -56,6 +58,8 @@
 forwardslash
 backwardslash
 under_score
+nonbreakingspace
+tabspace
 `
 
 	tests, expect = strings.TrimSpace(tests), strings.TrimSpace(expect)