From: Mischa POSLAWSKY Date: Thu, 25 Jan 2024 19:26:22 +0000 (+0100) Subject: font: html encode control characters X-Git-Url: http://git.shiar.net/sheet.git/commitdiff_plain/b5801a65807017ac784979afd9dd451fa6c7c16c font: html encode control characters Replace unintended commands (i.e. tab, newline) by rendered glyphs if declared by a font, such as C1 characters following CP-1252 in Unifont. --- diff --git a/font.plp b/font.plp index a460144..a9f3491 100644 --- a/font.plp +++ b/font.plp @@ -156,12 +156,13 @@ EOT my ($class, $name, $mnem, $entity, $string) = @{$info}; my $np = $class =~ /\bC\S\b/; # noprint if control or invalid # display literal character, with placeholder circle if non-spacing/enclosing - my $html = ($class =~ /\bM[ne]\b/ && chr 9676) . EscapeHTML(chr $cp); + my $html = $np ? !!$cover{$cp} && sprintf("&#%d;", $cp) : + ($class =~ /\bM[ne]\b/ && chr 9676) . EscapeHTML(chr $cp); say sprintf '%s', !$class ? ('l0', $cp, '', '') : ( $cover{$cp} ? $np ? 'l2' : 'l5' : $np ? 'Xi' : 'l1', $cp, !!$name && ": $name", - ($cover{$cp} || !$np) && $html + $html ); } say '';