match numbers and letters on highlight.

This commit is contained in:
fiatjaf
2023-12-31 15:23:32 -03:00
parent 5bc8b5bbde
commit d1d172b96c

View File

@@ -487,7 +487,7 @@ func shapeText(rawText []rune, fontSize int) (shaping.Output, []bool, []hlstate)
case hlNormal: case hlNormal:
if glyph.Codepoint == '#' && if glyph.Codepoint == '#' &&
len(buf.Info) > i+1 && len(buf.Info) > i+1 &&
unicode.In(buf.Info[i+1].Codepoint, unicode.Letter) { unicode.In(buf.Info[i+1].Codepoint, unicode.Nl) {
hlState = hlHashtag hlState = hlHashtag
} else if glyph.Codepoint == 'h' && } else if glyph.Codepoint == 'h' &&
len(buf.Info) > i+1 && len(buf.Info) > i+1 &&
@@ -509,7 +509,8 @@ func shapeText(rawText []rune, fontSize int) (shaping.Output, []bool, []hlstate)
} }
} else if glyph.Codepoint == '@' && } else if glyph.Codepoint == '@' &&
len(buf.Info) > i+1 && len(buf.Info) > i+1 &&
unicode.In(buf.Info[i+1].Codepoint, unicode.Letter) { unicode.In(buf.Info[i+1].Codepoint,
unicode.Nl, unicode.Number) {
hlState = hlMention hlState = hlMention
} }
case hlLink: case hlLink:
@@ -518,11 +519,11 @@ func shapeText(rawText []rune, fontSize int) (shaping.Output, []bool, []hlstate)
hlState = hlNormal hlState = hlNormal
} }
case hlMention: case hlMention:
if !unicode.In(glyph.Codepoint, unicode.Letter) { if !unicode.In(glyph.Codepoint, unicode.Nl) {
hlState = hlNormal hlState = hlNormal
} }
case hlHashtag: case hlHashtag:
if !unicode.In(glyph.Codepoint, unicode.Letter) { if !unicode.In(glyph.Codepoint, unicode.Nl) {
hlState = hlNormal hlState = hlNormal
} }
} }