Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
d0452065
Commit
d0452065
authored
Feb 26, 2017
by
Gervase Markham
Committed by
Dylan William Hardison
Feb 26, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 1174341 - only treat emphasis markdown based on spaces
parent
4480c8ca
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
21 deletions
+57
-21
Markdown.pm
Bugzilla/Markdown.pm
+8
-8
100markdown.t
t/100markdown.t
+21
-13
embedded-blockquote.md
t/markdown/embedded-blockquote.md
+9
-0
embedded-underscore.md
t/markdown/embedded-underscore.md
+19
-0
No files found.
Bugzilla/Markdown.pm
View file @
d0452065
...
...
@@ -350,38 +350,38 @@ sub _DoItalicsAndBold {
$text =~ s{ ^\* (?=\S) (.+?) (?<=\S) \* }{<em>$1</em>}gsx;
# <strong> must go first:
$text =~ s{ ( (?<=\
W
) __ (?=\S) (.+?[*_]*) (?<=\S) __ (?!\S) ) }
$text =~ s{ ( (?<=\
s
) __ (?=\S) (.+?[*_]*) (?<=\S) __ (?!\S) ) }
{
my $result = _has_multiple_underscores($2) ? $1 : "<strong>$2</strong>";
$result;
}gsxe;
$text =~ s{ (?<=\
W
) \*\* (?=\S) (.+?[*_]*) (?<=\S) \*\* }{<strong>$1</strong>}gsx;
$text =~ s{ (?<=\
s
) \*\* (?=\S) (.+?[*_]*) (?<=\S) \*\* }{<strong>$1</strong>}gsx;
$text =~ s{ ( (?<=\
W
) _ (?=\S) (.+?) (?<=\S) _ (?!\S) ) }
$text =~ s{ ( (?<=\
s
) _ (?=\S) (.+?) (?<=\S) _ (?!\S) ) }
{
my $result = _has_multiple_underscores($2) ? $1 : "<em>$2</em>";
$result;
}gsxe;
$text =~ s{ (?<=\
W
) \* (?=\S) (.+?) (?<=\S) \* }{<em>$1</em>}gsx;
$text =~ s{ (?<=\
s
) \* (?=\S) (.+?) (?<=\S) \* }{<em>$1</em>}gsx;
# And now, a second pass to catch nested strong and emphasis special cases
$text =~ s{ ( (?<=\
W
) __ (?=\S) (.+?[*_]*) (?<=\S) __ (\S*) ) }
$text =~ s{ ( (?<=\
s
) __ (?=\S) (.+?[*_]*) (?<=\S) __ (\S*) ) }
{
my $result = _has_multiple_underscores($3) ? $1 : "<strong>$2</strong>$3";
$result;
}gsxe;
$text =~ s{ (?<=\
W
) \*\* (?=\S) (.+?[*_]*) (?<=\S) \*\* }{<strong>$1</strong>}gsx;
$text =~ s{ ( (?<=\
W
) _ (?=\S) (.+?) (?<=\S) _ (\S*) ) }
$text =~ s{ (?<=\
s
) \*\* (?=\S) (.+?[*_]*) (?<=\S) \*\* }{<strong>$1</strong>}gsx;
$text =~ s{ ( (?<=\
s
) _ (?=\S) (.+?) (?<=\S) _ (\S*) ) }
{
my $result = _has_multiple_underscores($3) ? $1 : "<em>$2</em>$3";
$result;
}gsxe;
$text =~ s{ (?<=\
W
) \* (?=\S) (.+?) (?<=\S) \* }{<em>$1</em>}gsx;
$text =~ s{ (?<=\
s
) \* (?=\S) (.+?) (?<=\S) \* }{<em>$1</em>}gsx;
return $text;
}
...
...
t/100markdown.t
View file @
d0452065
...
...
@@ -12,7 +12,8 @@ use strict;
use warnings;
use lib qw(. lib local/lib/perl5 t);
use Test2::Bundle::Extended;
use Test2::Tools::Mock;
use Test::More;
use Bugzilla::Util;
BEGIN {
my $terms = {
...
...
@@ -45,6 +46,8 @@ use Bugzilla::Bug;
use Bugzilla::Comment;
use Bugzilla::User;
use Bugzilla::Markdown;
use Bugzilla::Util;
use File::Basename;
Bugzilla->usage_mode(USAGE_MODE_TEST);
Bugzilla->error_mode(ERROR_MODE_DIE);
...
...
@@ -71,19 +74,24 @@ my $comment = Bugzilla::Comment->new(already_wrapped => 0);
Bugzilla->set_user($user);
my $markdown_text = <<MARKDOWN;
```
this is a block
> with an embedded blockquote
```
MARKDOWN
my @testfiles = glob("t/markdown/*.md");
my $markdown = Bugzilla::Markdown->new(
);
plan(tests => scalar(@testfiles) + 1
);
my $markdown = Bugzilla::Markdown->new();
ok($markdown, "got a new markdown object");
my $markdown_html = $markdown->markdown($markdown_text, $bug, $comment);
is("<pre><code>this is a block\n"
. "> with an embedded blockquote</code></pre>\n",
$markdown_html, "code block with embedded block quote");
done_testing;
foreach my $testfile (@testfiles) {
my $data = read_text($testfile);
my ($markdown_text, $expected_html) = split(/---/, $data);
$markdown_text = trim($markdown_text);
$expected_html = trim($expected_html);
my $actual_html = $markdown->markdown($markdown_text, $bug, $comment);
$actual_html = trim($actual_html);
is($actual_html, $expected_html, basename($testfile));
}
done_testing();
t/markdown/embedded-blockquote.md
0 → 100644
View file @
d0452065
```
this is a block
> with an embedded blockquote
```
---
<pre><code>
this is a block
>
with an embedded blockquote
</code></pre>
t/markdown/embedded-underscore.md
0 → 100644
View file @
d0452065
<lib>
_foo_
bar.c
<lib>
_foo_
bar_baz.c
<prefix>
_bar.c and <prefix>_
bif.c
hello_bar.c and there_bif.c
var this__is_a_variable__ = "";
__this is not__
---
<p>
<
lib
>
_foo_
bar.c
<br>
<
lib
>
_foo_
bar_baz.c
<br>
<
prefix
>
_bar.c and <prefix>_
bif.c
<br>
hello_bar.c and there_bif.c
</p>
<p>
var this__is_a_variable__ =
""
;
</p>
<p><strong>
this is not
</strong></p>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment