Fix some utf8 and xml encoding stuff

This commit is contained in:
swag 2023-04-25 18:09:51 -04:00
parent 4554ed2e74
commit 419c61ed7f

View File

@ -12,11 +12,13 @@ package PostText::Markdown;
use v5.36; use v5.36;
use Digest::MD5 qw(md5_hex); use Digest::MD5 qw(md5_hex);
use Encode qw(encode_utf8);
use vars qw($VERSION); use vars qw($VERSION);
$VERSION = '1.0.1'; $VERSION = '1.0.1';
use Exporter qw{import}; use Exporter qw{import};
our @EXPORT = qw{Markdown}; our @EXPORT = qw{Markdown};
# Tue 14 Dec 2004 # Tue 14 Dec 2004
## Disabled; causes problems under Perl 5.6.1: ## Disabled; causes problems under Perl 5.6.1:
@ -188,7 +190,7 @@ sub _HashHTMLBlocks {
(?=\n+|\Z) # followed by a newline or end of document (?=\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; $g_html_blocks{$key} = $1;
"\n\n" . $key . "\n\n"; "\n\n" . $key . "\n\n";
}egmx; }egmx;
@ -208,7 +210,7 @@ sub _HashHTMLBlocks {
(?=\n+|\Z) # followed by a newline or end of document (?=\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; $g_html_blocks{$key} = $1;
"\n\n" . $key . "\n\n"; "\n\n" . $key . "\n\n";
}egmx; }egmx;
@ -230,7 +232,7 @@ sub _HashHTMLBlocks {
(?=\n{2,}|\Z) # followed by a blank line or end of document (?=\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; $g_html_blocks{$key} = $1;
"\n\n" . $key . "\n\n"; "\n\n" . $key . "\n\n";
}egx; }egx;
@ -253,7 +255,7 @@ sub _HashHTMLBlocks {
(?=\n{2,}|\Z) # followed by a blank line or end of document (?=\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; $g_html_blocks{$key} = $1;
"\n\n" . $key . "\n\n"; "\n\n" . $key . "\n\n";
}egx; }egx;
@ -846,7 +848,7 @@ sub _EncodeCode {
# Encode all ampersands; HTML entities are not # Encode all ampersands; HTML entities are not
# entities within a Markdown code span. # entities within a Markdown code span.
s/&/&/g; #s/&/&/g;
# Encode $'s, but only if we're running under Blosxom. # Encode $'s, but only if we're running under Blosxom.
# (Blosxom interpolates Perl variables in article bodies.) # (Blosxom interpolates Perl variables in article bodies.)