Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix backticks in inline code (replaces #503, fixes #312) #1013

Merged
merged 2 commits into from
Jan 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/marked.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,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 @@ -664,7 +664,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));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Feder1co5oave @joshbruce We have to watch out for changing capturing parentheses. This can be a breaking change. https://github.com/firede/msee/pull/59/files

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.