From ac1047815f227618e9cbab24ce0190d5c5c26527 Mon Sep 17 00:00:00 2001 From: Vladimir Vuksanovic Date: Fri, 4 Oct 2019 17:15:41 +0200 Subject: [PATCH] fix(lists): Fix tasklists to comply with GFM GFM requires a whitespace between brackets. Closes #655 --- src/subParsers/makehtml/lists.js | 4 ++-- test/functional/makehtml/cases/features/#164.4.tasklists.html | 3 ++- test/functional/makehtml/cases/features/#164.4.tasklists.md | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/subParsers/makehtml/lists.js b/src/subParsers/makehtml/lists.js index e22dcd1..1473a9c 100644 --- a/src/subParsers/makehtml/lists.js +++ b/src/subParsers/makehtml/lists.js @@ -40,7 +40,7 @@ showdown.subParser('makehtml.lists', function (text, options, globals) { // attacklab: add sentinel to emulate \z listStr += '¨0'; - var rgx = /(\n)?(^ {0,3})([*+-]|\d+[.])[ \t]+((\[(x|X| )?])?[ \t]*[^\r]+?(\n{1,2}))(?=\n*(¨0| {0,3}([*+-]|\d+[.])[ \t]+))/gm, + var rgx = /(\n)?(^ {0,3})([*+-]|\d+[.])[ \t]+((\[(x|X| )])?[ \t]*[^\r]+?(\n{1,2}))(?=\n*(¨0| {0,3}([*+-]|\d+[.])[ \t]+))/gm, isParagraphed = (/\n[ \t]*\n(?!¨0)/.test(listStr)); // Since version 1.5, nesting sublists requires 4 spaces (or 1 tab) indentation, @@ -48,7 +48,7 @@ showdown.subParser('makehtml.lists', function (text, options, globals) { // activating this option reverts to old behavior // This will be removed in version 2.0 if (options.disableForced4SpacesIndentedSublists) { - rgx = /(\n)?(^ {0,3})([*+-]|\d+[.])[ \t]+((\[(x|X| )?])?[ \t]*[^\r]+?(\n{1,2}))(?=\n*(¨0|\2([*+-]|\d+[.])[ \t]+))/gm; + rgx = /(\n)?(^ {0,3})([*+-]|\d+[.])[ \t]+((\[(x|X| )])?[ \t]*[^\r]+?(\n{1,2}))(?=\n*(¨0|\2([*+-]|\d+[.])[ \t]+))/gm; } listStr = listStr.replace(rgx, function (wholeMatch, m1, m2, m3, m4, taskbtn, checked) { diff --git a/test/functional/makehtml/cases/features/#164.4.tasklists.html b/test/functional/makehtml/cases/features/#164.4.tasklists.html index cf6ccdf..6a343fa 100644 --- a/test/functional/makehtml/cases/features/#164.4.tasklists.html +++ b/test/functional/makehtml/cases/features/#164.4.tasklists.html @@ -1,8 +1,9 @@

my things

otherthings

diff --git a/test/functional/makehtml/cases/features/#164.4.tasklists.md b/test/functional/makehtml/cases/features/#164.4.tasklists.md index 0054490..047eed3 100644 --- a/test/functional/makehtml/cases/features/#164.4.tasklists.md +++ b/test/functional/makehtml/cases/features/#164.4.tasklists.md @@ -4,5 +4,6 @@ - [] bar - [ ] baz - [x] bazinga + - [X] bazinga 2 otherthings