From b2a07608e102b4e7a164c99b9231b954a1efcec3 Mon Sep 17 00:00:00 2001 From: Federico Soave Date: Sat, 18 Oct 2014 13:04:16 +0200 Subject: [PATCH 1/2] fix backticks in inline code (fixes #312) --- lib/marked.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/marked.js b/lib/marked.js index 8fc72b3a3a..873427bca6 100644 --- a/lib/marked.js +++ b/lib/marked.js @@ -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]+?(?=[\\ Date: Fri, 12 Jan 2018 17:28:57 +0100 Subject: [PATCH 2/2] add tests for codespans with backticks in them --- test/new/nested_code.html | 8 ++++++++ test/new/nested_code.md | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/test/new/nested_code.html b/test/new/nested_code.html index c370592015..c28a162862 100644 --- a/test/new/nested_code.html +++ b/test/new/nested_code.html @@ -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.

\ No newline at end of file diff --git a/test/new/nested_code.md b/test/new/nested_code.md index 910e3d4628..adde417713 100644 --- a/test/new/nested_code.md +++ b/test/new/nested_code.md @@ -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 `` tags. \ No newline at end of file