mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
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
This commit is contained in:
parent
d62ede8e9e
commit
9b6e61464b
2 changed files with 5 additions and 5 deletions
|
@ -58,7 +58,7 @@ func sanitizeAnchorNameWithHook(b []byte, idType string, hook func(buf *bytes.Bu
|
||||||
r, size := utf8.DecodeRune(b)
|
r, size := utf8.DecodeRune(b)
|
||||||
switch {
|
switch {
|
||||||
case asciiOnly && size != 1:
|
case asciiOnly && size != 1:
|
||||||
case r == '-' || isSpace(r):
|
case r == '-' || r == ' ':
|
||||||
buf.WriteRune('-')
|
buf.WriteRune('-')
|
||||||
case isAlphaNumeric(r):
|
case isAlphaNumeric(r):
|
||||||
buf.WriteRune(unicode.ToLower(r))
|
buf.WriteRune(unicode.ToLower(r))
|
||||||
|
@ -85,10 +85,6 @@ func isAlphaNumeric(r rune) bool {
|
||||||
return r == '_' || unicode.IsLetter(r) || unicode.IsDigit(r)
|
return r == '_' || unicode.IsLetter(r) || unicode.IsDigit(r)
|
||||||
}
|
}
|
||||||
|
|
||||||
func isSpace(r rune) bool {
|
|
||||||
return r == ' ' || r == '\t'
|
|
||||||
}
|
|
||||||
|
|
||||||
var _ parser.IDs = (*idFactory)(nil)
|
var _ parser.IDs = (*idFactory)(nil)
|
||||||
|
|
||||||
type idFactory struct {
|
type idFactory struct {
|
||||||
|
|
|
@ -40,6 +40,8 @@ Many spaces here
|
||||||
Forward/slash
|
Forward/slash
|
||||||
Backward\slash
|
Backward\slash
|
||||||
Under_score
|
Under_score
|
||||||
|
Nonbreaking Space
|
||||||
|
Tab Space
|
||||||
`
|
`
|
||||||
|
|
||||||
expect := `
|
expect := `
|
||||||
|
@ -56,6 +58,8 @@ many---spaces--here
|
||||||
forwardslash
|
forwardslash
|
||||||
backwardslash
|
backwardslash
|
||||||
under_score
|
under_score
|
||||||
|
nonbreakingspace
|
||||||
|
tabspace
|
||||||
`
|
`
|
||||||
|
|
||||||
tests, expect = strings.TrimSpace(tests), strings.TrimSpace(expect)
|
tests, expect = strings.TrimSpace(tests), strings.TrimSpace(expect)
|
||||||
|
|
Loading…
Reference in a new issue