Skip to content

Commit

Permalink
Merge pull request markedjs#1013 from Feder1co5oave/fix-backticks2
Browse files Browse the repository at this point in the history
fix backticks in inline code (replaces markedjs#503, fixes markedjs#312)
  • Loading branch information
joshbruce authored Jan 20, 2018
2 parents 76ce107 + 3eaccd3 commit 7a55127
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/marked.js
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ var inline = {
nolink: /^!?\[((?:\[[^\]]*\]|\\[\[\]]|[^\[\]])*)\]/,
strong: /^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,
em: /^\b_((?:[^_]|__)+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,
code: /^(`+)([\s\S]*?[^`])\1(?!`)/,
code: /^(`+)(\s*)([\s\S]*?[^`]?)\2\1(?!`)/,
br: /^ {2,}\n(?!\s*$)/,
del: noop,
text: /^[\s\S]+?(?=[\\<!\[_*`]| {2,}\n|$)/
Expand Down Expand Up @@ -675,7 +675,7 @@ InlineLexer.prototype.output = function(src) {
// code
if (cap = this.rules.code.exec(src)) {
src = src.substring(cap[0].length);
out += this.renderer.codespan(escape(cap[2].trim(), true));
out += this.renderer.codespan(escape(cap[3].trim(), true));
continue;
}

Expand Down
8 changes: 8 additions & 0 deletions test/new/nested_code.html
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
<p><code>hi ther `` ok ```</code></p>

<p><code>`</code></p>

<p><code>There is a literal backtick (`) here.</code></p>

<p>A backtick-delimited string in a code span: <code>`foo`</code></p>

<p>Please don&#39;t use any <code>&lt;blink&gt;</code> tags.</p>
8 changes: 8 additions & 0 deletions test/new/nested_code.md
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
````` hi ther `` ok ``` `````

`` ` ``

``There is a literal backtick (`) here.``

A backtick-delimited string in a code span: `` `foo` ``

Please don't use any `<blink>` tags.

0 comments on commit 7a55127

Please sign in to comment.