Skip to content

Commit

Permalink
Merge pull request #1013 from Feder1co5oave/fix-backticks2
Browse files Browse the repository at this point in the history
fix backticks in inline code (replaces #503, fixes #312)
  • Loading branch information
joshbruce authored Jan 20, 2018
2 parents a78d51f + 4bc3126 commit a98bad2
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 a98bad2

Please sign in to comment.