From a4460a93019c1fe50bdab9412ffc87782aedf9cf Mon Sep 17 00:00:00 2001 From: barrywoolgar Date: Thu, 2 Aug 2018 18:27:40 +0100 Subject: [PATCH 1/4] Updated inline grammer regexes for strong and em Attempt to match special case single character matches before the more permissive standard regexes --- lib/marked.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/marked.js b/lib/marked.js index caa54243f9..b516ae8117 100644 --- a/lib/marked.js +++ b/lib/marked.js @@ -540,8 +540,8 @@ var inline = { link: /^!?\[(label)\]\(href(?:\s+(title))?\s*\)/, reflink: /^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/, 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*])\*(?!\*)/, + 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(?!`)/, br: /^( {2,}|\\)\n(?!\s*$)/, del: noop, From 935d1bbe8001c0c538880c0ab9b49af24a282d43 Mon Sep 17 00:00:00 2001 From: Barry Woolgar Date: Thu, 2 Aug 2018 23:56:48 +0100 Subject: [PATCH 2/4] Add tests covering single character strong and emphasis --- test/new/cm_strong_and_em.html | 7 +++++++ test/new/cm_strong_and_em.md | 7 +++++++ 2 files changed, 14 insertions(+) create mode 100644 test/new/cm_strong_and_em.html create mode 100644 test/new/cm_strong_and_em.md diff --git a/test/new/cm_strong_and_em.html b/test/new/cm_strong_and_em.html new file mode 100644 index 0000000000..084f638135 --- /dev/null +++ b/test/new/cm_strong_and_em.html @@ -0,0 +1,7 @@ +

So a single word followed by another

+ +

So a single word followed by another

+ +

So a single word followed by another

+ +

So a single word followed by another

diff --git a/test/new/cm_strong_and_em.md b/test/new/cm_strong_and_em.md new file mode 100644 index 0000000000..34b4a20b1f --- /dev/null +++ b/test/new/cm_strong_and_em.md @@ -0,0 +1,7 @@ +So *a* single *word* followed *b*y *a*nother + +So **a** single **word** followed **b**y **a**nother + +So _a_ single _word_ followed _b_y _a_nother + +So __a__ single __word__ followed __b__y __a__nother From 0ba25227cd7a70feb879487682744f77625d4048 Mon Sep 17 00:00:00 2001 From: Barry Woolgar Date: Fri, 3 Aug 2018 19:49:10 +0100 Subject: [PATCH 3/4] Exclude punctuation to make 333, 450, 452, 505, and 535, pass --- lib/marked.js | 3 ++- test/specs/commonmark/commonmark-spec.js | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/marked.js b/lib/marked.js index b516ae8117..575abe8b98 100644 --- a/lib/marked.js +++ b/lib/marked.js @@ -541,7 +541,8 @@ var inline = { reflink: /^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/, 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])\*(?!\*)/, + // em: /^_([^\s_])_(?!_)|^\*([^\s*])\*(?!\*)|^_([^\s][\s\S]*?[^\s_])_(?!_)|^_([^\s_][\s\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(?!`)/, br: /^( {2,}|\\)\n(?!\s*$)/, del: noop, diff --git a/test/specs/commonmark/commonmark-spec.js b/test/specs/commonmark/commonmark-spec.js index 3bc003fbb7..4a429f3ebf 100644 --- a/test/specs/commonmark/commonmark-spec.js +++ b/test/specs/commonmark/commonmark-spec.js @@ -334,7 +334,7 @@ describe('CommonMark 0.28 Emphasis and strong emphasis', function() { var section = 'Emphasis and strong emphasis'; // var shouldPassButFails = []; - var shouldPassButFails = [333, 334, 342, 348, 349, 352, 353, 354, 355, 356, 360, 368, 369, 371, 372, 378, 380, 381, 382, 387, 388, 392, 393, 394, 395, 396, 402, 403, 409, 416, 419, 420, 421, 422, 423, 424, 428, 431, 432, 433, 434, 435, 436, 443, 444, 445, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458]; + var shouldPassButFails = [334, 342, 348, 349, 352, 353, 354, 355, 356, 360, 368, 369, 371, 372, 378, 380, 381, 382, 387, 388, 392, 393, 394, 395, 396, 402, 403, 409, 416, 419, 420, 421, 422, 423, 424, 428, 431, 432, 433, 434, 435, 436, 443, 444, 445, 448, 449, 451, 453, 454, 455, 456, 457, 458]; var willNotBeAttemptedByCoreTeam = []; @@ -349,7 +349,7 @@ describe('CommonMark 0.28 Links', function() { var section = 'Links'; // var shouldPassButFails = []; - var shouldPassButFails = [474, 478, 483, 489, 490, 491, 492, 495, 496, 497, 499, 503, 504, 505, 507, 508, 509, 523, 535]; + var shouldPassButFails = [474, 478, 483, 489, 490, 491, 495, 496, 497, 499, 503, 504, 507, 508, 509, 523]; var willNotBeAttemptedByCoreTeam = []; From 431884f6a6131860b262bd0c8ac13510af0dada6 Mon Sep 17 00:00:00 2001 From: Barry Woolgar Date: Wed, 15 Aug 2018 15:39:24 +0100 Subject: [PATCH 4/4] Remove commented line --- lib/marked.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/marked.js b/lib/marked.js index 575abe8b98..6a71e9201f 100644 --- a/lib/marked.js +++ b/lib/marked.js @@ -541,7 +541,6 @@ var inline = { reflink: /^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/, 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])\*(?!\*)/, 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(?!`)/, br: /^( {2,}|\\)\n(?!\s*$)/,