|
@ -12,6 +12,7 @@ package Markdown; |
|
|
require 5.006_000; |
|
|
require 5.006_000; |
|
|
use strict; |
|
|
use strict; |
|
|
use warnings; |
|
|
use warnings; |
|
|
|
|
|
close(DATA) if fileno(DATA); |
|
|
|
|
|
|
|
|
use Digest::MD5 qw(md5_hex); |
|
|
use Digest::MD5 qw(md5_hex); |
|
|
use vars qw($VERSION); |
|
|
use vars qw($VERSION); |
|
@ -52,7 +53,7 @@ $g_nested_brackets = qr{ |
|
|
|
|
|
|
|
|
# Table of hash values for escaped characters: |
|
|
# Table of hash values for escaped characters: |
|
|
my %g_escape_table; |
|
|
my %g_escape_table; |
|
|
foreach my $char (split //, '\\`*_{}[]()>#+-.!~') { |
|
|
foreach my $char (split //, "\\\`*_{}[]()>#+-.!~") { |
|
|
$g_escape_table{$char} = md5_hex($char); |
|
|
$g_escape_table{$char} = md5_hex($char); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -316,7 +317,7 @@ sub _StripLinkDefinitions { |
|
|
$g_urls{lc $1} = _EncodeAmpsAndAngles( $2 ); # Link IDs are case-insensitive |
|
|
$g_urls{lc $1} = _EncodeAmpsAndAngles( $2 ); # Link IDs are case-insensitive |
|
|
if ($3) { |
|
|
if ($3) { |
|
|
$g_titles{lc $1} = $3; |
|
|
$g_titles{lc $1} = $3; |
|
|
$g_titles{lc $1} =~ s/"/"/g; |
|
|
$g_titles{lc $1} =~ s/\042/"/g; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -594,7 +595,7 @@ sub _DoAnchors { |
|
|
<?(.*?)>? # href = $3 |
|
|
<?(.*?)>? # href = $3 |
|
|
[ \t]* |
|
|
[ \t]* |
|
|
( # $4 |
|
|
( # $4 |
|
|
(['"]) # quote char = $5 |
|
|
(['\042]) # quote char = $5 |
|
|
(.*?) # Title = $6 |
|
|
(.*?) # Title = $6 |
|
|
\5 # matching quote |
|
|
\5 # matching quote |
|
|
)? # title is optional |
|
|
)? # title is optional |
|
@ -614,7 +615,7 @@ sub _DoAnchors { |
|
|
$result = "<a href=\"$url\""; |
|
|
$result = "<a href=\"$url\""; |
|
|
|
|
|
|
|
|
if (defined $title) { |
|
|
if (defined $title) { |
|
|
$title =~ s/"/"/g; |
|
|
$title =~ s/\042/"/g; |
|
|
$title =~ s! \* !$g_escape_table{'*'}!gx; |
|
|
$title =~ s! \* !$g_escape_table{'*'}!gx; |
|
|
$title =~ s! _ !$g_escape_table{'_'}!gx; |
|
|
$title =~ s! _ !$g_escape_table{'_'}!gx; |
|
|
$title =~ s! ~ !$g_escape_table{'~'}!gx; |
|
|
$title =~ s! ~ !$g_escape_table{'~'}!gx; |
|
@ -701,7 +702,7 @@ sub _DoImages { |
|
|
<?(\S+?)>? # src url = $3 |
|
|
<?(\S+?)>? # src url = $3 |
|
|
[ \t]* |
|
|
[ \t]* |
|
|
( # $4 |
|
|
( # $4 |
|
|
(['"]) # quote char = $5 |
|
|
(['\042]) # quote char = $5 |
|
|
(.*?) # title = $6 |
|
|
(.*?) # title = $6 |
|
|
\5 # matching quote |
|
|
\5 # matching quote |
|
|
[ \t]* |
|
|
[ \t]* |
|
@ -1231,7 +1232,7 @@ sub _EncodeBackslashEscapes { |
|
|
sub _DoAutoLinks { |
|
|
sub _DoAutoLinks { |
|
|
my $text = shift; |
|
|
my $text = shift; |
|
|
|
|
|
|
|
|
$text =~ s{<((https?|ftp):[^'">\s]+)>}{<a href="$1">$1</a>}gi; |
|
|
$text =~ s{<((https?|ftp):[^'\042>\s]+)>}{<a href="$1">$1</a>}gi; |
|
|
|
|
|
|
|
|
# Email addresses: <address@domain.foo> |
|
|
# Email addresses: <address@domain.foo> |
|
|
$text =~ s{ |
|
|
$text =~ s{ |
|
@ -1400,7 +1401,7 @@ sub _PrefixURL { |
|
|
|
|
|
|
|
|
1; |
|
|
1; |
|
|
|
|
|
|
|
|
__END__ |
|
|
__DATA__ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
=pod |
|
|
=pod |
|
|