Skip to content

Commit

Permalink
add more edge cases
Browse files Browse the repository at this point in the history
  • Loading branch information
UziTech committed Apr 5, 2018
1 parent 6ce9c09 commit 81e01d4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/marked.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,8 @@ var inline = {
link: /^!?\[(inside)\]\(href\)/,
reflink: /^!?\[(inside)\]\s*\[([^\]]*)\]/,
nolink: /^!?\[((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\]/,
strong: /^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,
em: /^_([^\s_](?:[^_]|__)*?[^\s_]?)_\b|^\*((?:\*\*|[^*])+?)\*(?!\*)/,
strong: /^__([^\s][\s\S]*?[^\s])__(?!_)|^\*\*([^\s][\s\S]*?[^\s])\*\*(?!\*)|^__([^\s])__(?!_)|^\*\*([^\s])\*\*(?!\*)/,
em: /^_([^\s][\s\S]*?[^\s_])_(?!_)|^_([^\s_][\s\S]*?[^\s])_(?!_)|^\*([^\s][\s\S]*?[^\s*])\*(?!\*)|^\*([^\s*][\s\S]*?[^\s])\*(?!\*)|^_([^\s_])_(?!_)|^\*([^\s*])\*(?!\*)/,
code: /^(`+)\s*([\s\S]*?[^`]?)\s*\1(?!`)/,
br: /^ {2,}\n(?!\s*$)/,
del: noop,
Expand Down Expand Up @@ -678,14 +678,14 @@ InlineLexer.prototype.output = function(src) {
// strong
if (cap = this.rules.strong.exec(src)) {
src = src.substring(cap[0].length);
out += this.renderer.strong(this.output(cap[2] || cap[1]));
out += this.renderer.strong(this.output(cap[4] || cap[3] || cap[2] || cap[1]));
continue;
}

// em
if (cap = this.rules.em.exec(src)) {
src = src.substring(cap[0].length);
out += this.renderer.em(this.output(cap[2] || cap[1]));
out += this.renderer.em(this.output(cap[6] || cap[5] || cap[4] || cap[3] || cap[2] || cap[1]));
continue;
}

Expand Down
10 changes: 10 additions & 0 deletions test/new/em_2char.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,13 @@
<p>__</p>

<p>**</p>

<p>_123 _</p>

<p>*123 *</p>

<p>_ 123_</p>

<p><em>1_</em></p>

<p><em>1*</em></p>
10 changes: 10 additions & 0 deletions test/new/em_2char.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,13 @@ _1_
__

**

_123 _

*123 *

_ 123_

_1__

*1**

0 comments on commit 81e01d4

Please sign in to comment.