diff --git a/Markdown.pl b/Markdown.pl index d9b5e55..1ddb3a1 100755 --- a/Markdown.pl +++ b/Markdown.pl @@ -2001,11 +2001,30 @@ sub _EncodeCode { sub _DoItalicsAndBoldAndStrike { my $text = shift; + my $doital1 = sub { + my $text = shift; + $text =~ s{ \* (?=\S) (.+?) (?<=\S) \* } + {$1}gsx; + # We've got to encode any of these remaining to + # avoid conflicting with other italics and bold. + $text =~ s!([*])!$g_escape_table{$1}!g; + $text; + }; + my $doital2 = sub { + my $text = shift; + $text =~ s{ (?$1}gsx; + # We've got to encode any of these remaining to + # avoid conflicting with other italics and bold. + $text =~ s!([_])!$g_escape_table{$1}!g; + $text; + }; + # must go first: $text =~ s{ \*\* (?=\S) (.+?[*_]*) (?<=\S) \*\* } - {$1}gsx; + {"".&$doital1($1).""}gsex; $text =~ s{ (?$1}gsx; + {"".&$doital2($1).""}gsex; $text =~ s{ ~~ (?=\S) (.+?[*_]*) (?<=\S) ~~ } {$1}gsx;