diff options
author | 2024-12-08 16:03:00 +0100 | |
---|---|---|
committer | 2024-12-08 16:03:00 +0100 | |
commit | 9477fd7eba9bda6813b65c6c54380904892ca35e (patch) | |
tree | c67608e4ea06ff32b54f77366a10e70565bee0c9 /internal/text/util.go | |
parent | [chore] stub /api/v1/accounts/{id}/featured_tags endpoint (#3598) (diff) | |
download | gotosocial-9477fd7eba9bda6813b65c6c54380904892ca35e.tar.xz |
[feature] Allow partial-word hashtags using non-breaking spaces (#3606)
* [feature] Allow partial-word hashtags using non-breaking spaces
* update docs
Diffstat (limited to 'internal/text/util.go')
-rw-r--r-- | internal/text/util.go | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/internal/text/util.go b/internal/text/util.go index 204c64838..af45cfaf0 100644 --- a/internal/text/util.go +++ b/internal/text/util.go @@ -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 |