summaryrefslogtreecommitdiff
path: root/internal/text/util.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/text/util.go')
-rw-r--r--internal/text/util.go30
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