From 3271b8b62ec143d6b50d09c6774a121045789463 Mon Sep 17 00:00:00 2001 From: Tony Brix Date: Sat, 15 Sep 2018 22:47:18 -0500 Subject: [PATCH 1/2] fix inline code regex --- lib/marked.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/marked.js b/lib/marked.js index d635f2449e..f1fc7dd7c8 100644 --- a/lib/marked.js +++ b/lib/marked.js @@ -542,7 +542,7 @@ var inline = { nolink: /^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/, 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(?!`)/, + code: /^(`+)([\s\S]*?[^`]?)\1(?!`)/, br: /^( {2,}|\\)\n(?!\s*$)/, del: noop, text: /^[\s\S]+?(?=[\\ Date: Tue, 18 Sep 2018 16:33:23 -0500 Subject: [PATCH 2/2] fix a few more spec examples --- lib/marked.js | 6 +++--- test/specs/commonmark/commonmark-spec.js | 3 +-- test/specs/marked/marked.json | 8 +++++++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/marked.js b/lib/marked.js index f1fc7dd7c8..b9c838de06 100644 --- a/lib/marked.js +++ b/lib/marked.js @@ -542,10 +542,10 @@ var inline = { nolink: /^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/, 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]*?[^`]?)\1(?!`)/, + code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, br: /^( {2,}|\\)\n(?!\s*$)/, del: noop, - text: /^[\s\S]+?(?=[\\?@\[\]\\^_`{|}~])/g; @@ -611,7 +611,7 @@ inline.gfm = merge({}, inline.normal, { del: /^~+(?=\S)([\s\S]*?\S)~+/, text: edit(inline.text) .replace(']|', '~]|') - .replace('|', '|https?://|ftp://|www\\.|[a-zA-Z0-9.!#$%&\'*+/=?^_`{\\|}~-]+@|') + .replace('|$', '|https?://|ftp://|www\\.|[a-zA-Z0-9.!#$%&\'*+/=?^_`{\\|}~-]+@|$') .getRegex() }); diff --git a/test/specs/commonmark/commonmark-spec.js b/test/specs/commonmark/commonmark-spec.js index 4a429f3ebf..bebf65b42b 100644 --- a/test/specs/commonmark/commonmark-spec.js +++ b/test/specs/commonmark/commonmark-spec.js @@ -318,8 +318,7 @@ describe('CommonMark 0.28 Entity and numeric character references', function() { describe('CommonMark 0.28 Code spans', function() { var section = 'Code spans'; - // var shouldPassButFails = []; - var shouldPassButFails = [330, 316, 328, 320, 323, 322]; + var shouldPassButFails = [322, 323]; var willNotBeAttemptedByCoreTeam = []; diff --git a/test/specs/marked/marked.json b/test/specs/marked/marked.json index 5332e494d8..1afeea3457 100644 --- a/test/specs/marked/marked.json +++ b/test/specs/marked/marked.json @@ -77,6 +77,12 @@ "html": "

((http://foo.com.))

", "example": 13 }, + { + "section": "Code spans", + "markdown": "``*test`*", + "html": "

``test`

", + "example": 14 + }, { "section": "Autolinks", "markdown": "~~hello@email.com~~", @@ -89,4 +95,4 @@ "html": "

me@example.com

", "example": 1327 } -] \ No newline at end of file +]