From 3f312a3f34775690f5c7057527c00d186b1cafd7 Mon Sep 17 00:00:00 2001 From: Ilya Chesnokov Date: Thu, 17 Dec 2015 23:07:07 +0300 Subject: [PATCH 1/2] Fix incorrect centering for UTF-8 characters --- lib/Vroom.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Vroom.pm b/lib/Vroom.pm index 90fa2c4..769c1ea 100644 --- a/lib/Vroom.pm +++ b/lib/Vroom.pm @@ -465,7 +465,7 @@ sub buildSlides { $slide =~ s/^.{$undent}//gm; } $slide =~ s{^\ *==\ +(.*?)\ *$} - {' ' x (($self->config->{width} - length($1)) / 2) . $1}gem; + {' ' x (($self->config->{width} - length(decode_utf8($1))) / 2) . $1}gem; my $suf = $suffix++; $suf = $suf eq 'a' ? '' From 5a5c3157725b60405aafeacec7f05a0804c7da6f Mon Sep 17 00:00:00 2001 From: Ilya Chesnokov Date: Thu, 17 Dec 2015 23:14:49 +0300 Subject: [PATCH 2/2] ...and for "center" directive as well --- lib/Vroom.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Vroom.pm b/lib/Vroom.pm index 769c1ea..4f5c3c4 100644 --- a/lib/Vroom.pm +++ b/lib/Vroom.pm @@ -674,7 +674,7 @@ sub applyOptions { $slide ||= ''; if ($config->{center}) { $slide =~ s{^(\+?)\ *(.*?)\ *$} - {$1 . ' ' x (($self->config->{width} - length($2)) / 2) . $2}gem; + {$1 . ' ' x (($self->config->{width} - length(decode_utf8($2))) / 2) . $2}gem; $slide =~ s{^\s*$}{}gm; } elsif (defined $config->{indent}) {