A little improvement for repeated character handling.

This commit is contained in:
Storm Dragon committed 2026-10-30 12:25:31 -04:00
1 parent 36736725ea
commit 2c893dccb9
4 files changed
+55 -14

No files matched your search

+4 -4
View File
@@ -49,9 +49,9 @@ func (p *Processor) process_token(token, level string, options TextOptions) stri
if options.RepeatedSymbols && options.RepeatedSymbolsMin >= 2 && token != "" {
repeated := token
prefix, suffix := "", ""
// Progress bars commonly enclose a repeated run in brackets. Keep
// those delimiters under ordinary punctuation handling. Inside them,
// summarize each run, including partially filled bars such as [####----].
// Progress bars commonly enclose repeated runs in brackets. Keep
// those delimiters under ordinary punctuation handling. Symbol-only
// tokens, including diffstats such as +++++-----, summarize each run.
if len(token) >= 2 {
for _, pair := range []string{"[]", "()", "{}", "<>"} {
if token[0] == pair[0] && token[len(token)-1] == pair[1] {
@@ -63,7 +63,7 @@ func (p *Processor) process_token(token, level string, options TextOptions) stri
}
chars := []rune(repeated)
for _, char := range chars {
if !(unicode.IsPunct(char) || unicode.IsSymbol(char)) || prefix == "" && char != chars[0] {
if !(unicode.IsPunct(char) || unicode.IsSymbol(char)) {
return p.Text(token, level)
}
}