Skip to content

Commit

Permalink
Merge pull request markedjs#1181 from UziTech/em-less-than-2-chars
Browse files Browse the repository at this point in the history
Em less than 3 chars
  • Loading branch information
styfle committed Apr 5, 2018
2 parents d533040 + 0b991ae commit efd96bf
Show file tree
Hide file tree
Showing 3 changed files with 54 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
25 changes: 25 additions & 0 deletions test/new/em_2char.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<p><em>123</em></p>

<p><em>123</em></p>

<p><em>12</em></p>

<p><em>12</em></p>

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

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

<p>__</p>

<p>**</p>

<p>_123 _</p>

<p>*123 *</p>

<p>_ 123_</p>

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

<p><em>1*</em></p>
25 changes: 25 additions & 0 deletions test/new/em_2char.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
_123_

*123*

_12_

*12*

_1_

*1*

__

**

_123 _

*123 *

_ 123_

_1__

*1**

0 comments on commit efd96bf

Please sign in to comment.