From b5801a65807017ac784979afd9dd451fa6c7c16c Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Thu, 25 Jan 2024 20:26:22 +0100 Subject: [PATCH] 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. --- font.plp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 ''; -- 2.30.0