[feature] Allow partial-word hashtags using non-breaking spaces (#3606)

* [feature] Allow partial-word hashtags using non-breaking spaces

* update docs
This commit is contained in:
tobi
2024-12-08 16:03:00 +01:00
committed by GitHub
parent 642f5230e6
commit 9477fd7eba
3 changed files with 44 additions and 2 deletions

View File

@@ -38,8 +38,34 @@ func isPermittedInHashtag(r rune) bool {
// is a recognized break character for before
// or after a #hashtag.
func isHashtagBoundary(r rune) bool {
return unicode.IsSpace(r) ||
(unicode.IsPunct(r) && r != '_')
switch {
// Zero width space.
case r == '\u200B':
return true
// Zero width no-break space.
case r == '\uFEFF':
return true
// Pipe character sometimes
// used as workaround.
case r == '|':
return true
// Standard Unicode white space.
case unicode.IsSpace(r):
return true
// Non-underscore punctuation.
case unicode.IsPunct(r) && r != '_':
return true
// Not recognized
// hashtag boundary.
default:
return false
}
}
// isMentionBoundary returns true if rune r