about summary refs log tree commit homepage
path: root/lib/PublicInbox/Hval.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2015-12-24 01:56:22 +0000
committerEric Wong <e@80x24.org>2016-04-05 18:58:27 +0000
commit49d99dc0f71ab2d0f23a074765ef10d55d5d5547 (patch)
tree7a16acd9e9b92035c654843f445e921d27542754 /lib/PublicInbox/Hval.pm
parent854862946453e829243735e22c6cabc43b47a70c (diff)
downloadpublic-inbox-49d99dc0f71ab2d0f23a074765ef10d55d5d5547.tar.gz
Hopefully we'll show some names properly in our pages now,
as well as simplify our code when escaping text for HTML
display.

Additionally, tweak our diff display by using <ins> and
<del> tags for added/removed text, respectively.  This should
allow users to choose their own styles when viewing diffs
in their browser while being meaningful to people who cannot
differentiate colors.
Diffstat (limited to 'lib/PublicInbox/Hval.pm')
-rw-r--r--lib/PublicInbox/Hval.pm7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/PublicInbox/Hval.pm b/lib/PublicInbox/Hval.pm
index a16cd4a1..2974c683 100644
--- a/lib/PublicInbox/Hval.pm
+++ b/lib/PublicInbox/Hval.pm
@@ -10,7 +10,7 @@ use Encode qw(find_encoding);
 use URI::Escape qw(uri_escape_utf8);
 use PublicInbox::MID qw/mid_clean/;
 use base qw/Exporter/;
-our @EXPORT_OK = qw/ascii_html/;
+our @EXPORT_OK = qw/ascii_html utf8_html/;
 
 # for user-generated content (UGC) which may have excessively long lines
 # and screw up rendering on some browsers.  This is the only CSS style
@@ -71,6 +71,11 @@ sub ascii_html {
         $enc_ascii->encode($s, Encode::HTMLCREF);
 }
 
+sub utf8_html {
+        my ($raw) = @_;
+        ascii_html($enc_utf8->decode($raw));
+}
+
 sub as_html { ascii_html($_[0]->{raw}) }
 sub as_href { ascii_html(uri_escape_utf8($_[0]->{href})) }