From 419c61ed7f2f4d5619693eacd62a744cff94c5f1 Mon Sep 17 00:00:00 2001 From: swag Date: Tue, 25 Apr 2023 18:09:51 -0400 Subject: [PATCH] Fix some utf8 and xml encoding stuff --- lib/PostText/Markdown.pm | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/PostText/Markdown.pm b/lib/PostText/Markdown.pm index a43d956..b732802 100644 --- a/lib/PostText/Markdown.pm +++ b/lib/PostText/Markdown.pm @@ -12,11 +12,13 @@ package PostText::Markdown; use v5.36; use Digest::MD5 qw(md5_hex); +use Encode qw(encode_utf8); use vars qw($VERSION); $VERSION = '1.0.1'; use Exporter qw{import}; our @EXPORT = qw{Markdown}; + # Tue 14 Dec 2004 ## Disabled; causes problems under Perl 5.6.1: @@ -188,7 +190,7 @@ sub _HashHTMLBlocks { (?=\n+|\Z) # followed by a newline or end of document ) }{ - my $key = md5_hex($1); + my $key = md5_hex(encode_utf8($1)); $g_html_blocks{$key} = $1; "\n\n" . $key . "\n\n"; }egmx; @@ -208,7 +210,7 @@ sub _HashHTMLBlocks { (?=\n+|\Z) # followed by a newline or end of document ) }{ - my $key = md5_hex($1); + my $key = md5_hex(encode_utf8($1)); $g_html_blocks{$key} = $1; "\n\n" . $key . "\n\n"; }egmx; @@ -230,7 +232,7 @@ sub _HashHTMLBlocks { (?=\n{2,}|\Z) # followed by a blank line or end of document ) }{ - my $key = md5_hex($1); + my $key = md5_hex(encode_utf8($1)); $g_html_blocks{$key} = $1; "\n\n" . $key . "\n\n"; }egx; @@ -253,7 +255,7 @@ sub _HashHTMLBlocks { (?=\n{2,}|\Z) # followed by a blank line or end of document ) }{ - my $key = md5_hex($1); + my $key = md5_hex(encode_utf8($1)); $g_html_blocks{$key} = $1; "\n\n" . $key . "\n\n"; }egx; @@ -846,7 +848,7 @@ sub _EncodeCode { # Encode all ampersands; HTML entities are not # entities within a Markdown code span. - s/&/&/g; + #s/&/&/g; # Encode $'s, but only if we're running under Blosxom. # (Blosxom interpolates Perl variables in article bodies.)