Compare commits
2 Commits
3459e91645
...
da24af38e3
| Author | SHA1 | Date | |
|---|---|---|---|
| da24af38e3 | |||
| 6670e81640 |
@@ -288,8 +288,8 @@ sub parse_inline {
|
|||||||
push @bold_parts, { type => 'bold', content => $1 };
|
push @bold_parts, { type => 'bold', content => $1 };
|
||||||
return "\x01B$idx\x02";
|
return "\x01B$idx\x02";
|
||||||
}->()/ge;
|
}->()/ge;
|
||||||
$text =~ s/___((?:[^_]|_(?!_))+?)___/<strong>$1<\/strong>/g;
|
$text =~ s/(?<!\w)___((?:[^_]|_(?!_))+?)___(?!\w)/<strong>$1<\/strong>/g;
|
||||||
$text =~ s/__((?:[^_]|_(?!_))+?)__/<strong>$1<\/strong>/g;
|
$text =~ s/(?<!\w)__((?:[^_]|_(?!_))+?)__(?!\w)/<strong>$1<\/strong>/g;
|
||||||
|
|
||||||
my @italic_parts;
|
my @italic_parts;
|
||||||
my $italic_idx = 0;
|
my $italic_idx = 0;
|
||||||
@@ -298,7 +298,7 @@ sub parse_inline {
|
|||||||
push @italic_parts, { type => 'italic', content => $1 };
|
push @italic_parts, { type => 'italic', content => $1 };
|
||||||
return "\x01I$idx\x02";
|
return "\x01I$idx\x02";
|
||||||
}->()/ge;
|
}->()/ge;
|
||||||
$text =~ s/_([^_]+)_/sub {
|
$text =~ s/(?<!\w)_((?:[^_]|_(?!_))+?)_(?!\w)/sub {
|
||||||
my $idx = $italic_idx++;
|
my $idx = $italic_idx++;
|
||||||
push @italic_parts, { type => 'italic', content => $1 };
|
push @italic_parts, { type => 'italic', content => $1 };
|
||||||
return "\x01I$idx\x02";
|
return "\x01I$idx\x02";
|
||||||
@@ -312,7 +312,7 @@ sub parse_inline {
|
|||||||
push @italic_parts, { type => 'italic', content => $1 };
|
push @italic_parts, { type => 'italic', content => $1 };
|
||||||
return "\x01I$idx\x02";
|
return "\x01I$idx\x02";
|
||||||
}->()/ge;
|
}->()/ge;
|
||||||
$content =~ s/_([^_]+)_/sub {
|
$content =~ s/(?<!\w)_((?:[^_]|_(?!_))+?)_(?!\w)/sub {
|
||||||
my $idx = $italic_idx++;
|
my $idx = $italic_idx++;
|
||||||
push @italic_parts, { type => 'italic', content => $1 };
|
push @italic_parts, { type => 'italic', content => $1 };
|
||||||
return "\x01I$idx\x02";
|
return "\x01I$idx\x02";
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
use Test::More tests => 11;
|
use Test::More tests => 13;
|
||||||
use MarkdownParser;
|
use MarkdownParser;
|
||||||
|
|
||||||
my $parser = MarkdownParser->new();
|
my $parser = MarkdownParser->new();
|
||||||
@@ -62,4 +62,7 @@ is(
|
|||||||
"<p><strong>bold text</strong></p>\n",
|
"<p><strong>bold text</strong></p>\n",
|
||||||
"Bold with ___"
|
"Bold with ___"
|
||||||
);
|
);
|
||||||
|
is( $parser->parse("my_variable"),
|
||||||
|
"<p>my_variable</p>\n", "Underscore inside word unchanged" );
|
||||||
|
is( $parser->parse("CONST__VALUE"),
|
||||||
|
"<p>CONST__VALUE</p>\n", "Double underscores inside word unchanged" );
|
||||||
|
|||||||
Reference in New Issue
Block a user