3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-10-01 17:16:39 +02:00

Replace U+200b (zwsp) with U+feff (zwnbsp)

U+feff is now used instead of U+200b for nick-dehighlighting.

U+feff is non-breaking; it will not break-up the word when wrapping. It also
appears to be much more widely supported. In fact, some terminals will simply
strip the bytes -- this allows copying the text as-is, etc.

Additionally, an exclude-list was added to prevent dehighlighting of specific
nicknames. This is because several terminals do not fully support Unicode's
zero-width spaces -- they show up as plain spaces. Certain words for the #c
channel have been added to this exclude list since they are also somewhat
popular as nicknames there.
This commit is contained in:
Pragmatic Software 2022-01-18 10:32:21 -08:00
parent ef04c3eb12
commit e421f9b6bc
2 changed files with 6 additions and 3 deletions

View File

@ -797,6 +797,8 @@ sub truncate_result {
return $text;
}
my @dehighlight_exclusions = qw/auto if unsigned break inline void case int volatile char long while const register _Alignas continue restrict _Alignof default return _Atomic do short _Bool double signed _Complex else sizeof _Generic enum static _Imaginary extern struct _Noreturn float switch _Static_assert for typedef _Thread_local goto union/;
sub dehighlight_nicks {
my ($self, $line, $channel) = @_;
@ -810,10 +812,11 @@ sub dehighlight_nicks {
$potential_nick =~ s/[^\w\[\]\-\\\^\{\}]+$//;
next if length $potential_nick == 1;
next if grep { /\Q$potential_nick/i } @dehighlight_exclusions;
next if not $self->{pbot}->{nicklist}->is_present($channel, $potential_nick);
my $dehighlighted_nick = $potential_nick;
$dehighlighted_nick =~ s/(.)/$1\x{200b}/;
$dehighlighted_nick =~ s/(.)/$1\x{feff}/;
$token =~ s/\Q$potential_nick\E(?!:)/$dehighlighted_nick/;
}

View File

@ -25,8 +25,8 @@ use PBot::Imports;
# These are set by the /misc/update_version script
use constant {
BUILD_NAME => "PBot",
BUILD_REVISION => 4432,
BUILD_DATE => "2022-01-03",
BUILD_REVISION => 4442,
BUILD_DATE => "2022-01-18",
};
sub initialize {}