From 9cfe8b141259de9c0c7086155fed654140448ddf Mon Sep 17 00:00:00 2001 From: Estevao Soares dos Santos Date: Wed, 9 Nov 2016 02:54:18 +0000 Subject: [PATCH] fix(lists): fix sublists inconsistent behavior Nested ul and ol lists behave inconsistently in the requirement of having 3 spaces to be considered a nested list. This fix changes the requirement to only one space in both cases. Closes #299 --- dist/showdown.js | Bin 69923 -> 69838 bytes dist/showdown.js.map | Bin 207117 -> 206786 bytes dist/showdown.min.js | Bin 28289 -> 28236 bytes dist/showdown.min.js.map | Bin 31989 -> 31918 bytes src/subParsers/lists.js | 10 +++------ ...-unordered-list-inconsistent-behavior.html | 20 ++++++++++++++++++ ...ed-unordered-list-inconsistent-behavior.md | 12 +++++++++++ 7 files changed, 35 insertions(+), 7 deletions(-) create mode 100644 test/issues/#299.nested-ordered-unordered-list-inconsistent-behavior.html create mode 100644 test/issues/#299.nested-ordered-unordered-list-inconsistent-behavior.md diff --git a/dist/showdown.js b/dist/showdown.js index 01d9975c658dba08540576138754fd10781daac2..81bc73cbeb21495acf5761307c5c0bae167f4218 100644 GIT binary patch delta 91 zcmZ3yh~?Zu76EI0Ek%XmjQsMH{PH{n1Ivv9JMT04Pd;_uPCh0@J4P>BA*Li&KRs8$ qN`$!!PuH^)Cd%*>{vkd~NJyjk%%lNJEh`5_+w delta 115 zcmX@NkY({A76EI0Ek%XmjQsMH{PH{n1EY-sJMS}wPCj+tZt{nR+M+sK3SdxNn&gvN zTvDuHs}LQ#S^dFTrpd~a#1vq{dO4|i=_MJ~3fkJ4nhMoiP+hf?8xM+XW`2B_dGpz4 Gj9LI(@hJuX diff --git a/dist/showdown.js.map b/dist/showdown.js.map index 87da1fedd44ead7922dfacd290c24a8715086b63..dae8a338fce83638c996da4fbd09961c24c51ce8 100644 GIT binary patch delta 232 zcmeCZ#B=C8Ps0|*XKN-uu#%hnz?60Rh3|~QlLIsaCMU45!UQ9iig_xL9quv$g>|{6 ze^|$8GTmMt=%73`M*iv1>luT$U)jufm2Gm}S`Nm%?FV-;S~4={czaAg7{jPC`9lKN zUC`{{qaG3krx#N;V}L2+r4 zPiApRv4X8abnJGOuS~C*razEo7L$ZY=;fs5rI%z_D`;zHYARI6)Y25U*P*GSj4Rf@^8QPNJ* zRjas1L)@k`g z8XyZYYz?e4Y|`{{QuESFGOV?=Gc>JhQ*(+_71BY9xvYy)OG=CK6w+%a3&zNA4vm`6 Z$gEilw8BYza<+x!WdA6(%?2?tLI6^OPOks} diff --git a/dist/showdown.min.js.map b/dist/showdown.min.js.map index e891a15c6fec9a2e0dab7d36511c53a9936984ae..2e90ab4f587ef244e5d8a04b5bc8a9163e8e30ba 100644 GIT binary patch delta 2242 zcma)7OK%%h6jo3LkpgXbrHb0Lp#?;h+c*z9wj~sC@14nbJQ+_W6W4K&C~gwlvByqq zkH?Qh3QLxVE3pEJZn{K>ELb8W*sy?2*Ja5sU{O|_bH)jcgbP=A%<6E-&%Rw>ewTB*cmE2gi98hJ948yoQ9W;~06B3oSL2cjw< zmoLn=`l>SX%A$=R3e1CqL-kAL;XMNdMb7 zt#=#i7~VRxz)fG$x|G@tOjZJfBV|le9slhsv&4LfxGltN_1M4te%wT6LP@PJVEpnb zgddf~twqFULkDf1fR?zRN(i=0x(?_%7j;R&QiAIoLYP~K)FWm}?WkiNbrjr~ z3rXe?0A~j)-tI?@s++WG_o)jOEmf#~4z^BO*fefM-N6;H1B&PYLq?M3+#5tqAh}IN z^aT=b5_9>qgCV?*1Q!^8>~EJkY9E@UDZ*DKHJURVBKLrjx{ywN+0C3J98l@ogn>Mq z$~rn`tLunp2kVguG3#Jbo5sLRVp0?OZ}C+=(ja@f79%(m#~>!m6iIAw!QG}b29q!V zk{s1e`07dmXP8sJ-DTozEoor(J<6UIaWb&U+lG?C+Gt=Fy(Z%7yYO~mNIBg^28rLo zLY;k@h)s-RcGl3RzzqopEwy3^yi!PFU91rh~Y)pM#_dM zHhclYiPHyn2JXdr<-Af@wT(dzf!V0Z#RYYNC?eGIA+yz|gUJ&ZT%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9ekaLq$VV!24NAM^7W3ND7~q2^sAGlXJ60w_fd#wyzrE zDCqtvn?3y#p#^NN&bS zeh7k8T~+=(c_ld}TsM>tr?t|;s1`c%J Y+-cznH`@+QxW|!8-B(GNNLl{)U%p0dg#Z8m diff --git a/src/subParsers/lists.js b/src/subParsers/lists.js index c2a6789..a1608cb 100644 --- a/src/subParsers/lists.js +++ b/src/subParsers/lists.js @@ -102,9 +102,8 @@ showdown.subParser('lists', function (text, options, globals) { */ function parseConsecutiveLists(list, listType, trimTrailing) { // check if we caught 2 or more consecutive lists by mistake - // we use the counterRgx, meaning if listType is UL we look for UL and vice versa - var counterRxg = (listType === 'ul') ? /^ {0,2}\d+\.[ \t]/gm : /^ {0,2}[*+-][ \t]/gm, - subLists = [], + // we use the counterRgx, meaning if listType is UL we look for OL and vice versa + var counterRxg = (listType === 'ul') ? /^\d+\.[ \t]/gm : /^[*+-][ \t]/gm, result = ''; if (list.search(counterRxg) !== -1) { @@ -124,9 +123,6 @@ showdown.subParser('lists', function (text, options, globals) { result += '\n<' + listType + '>\n' + processListItems(txt, !!trimTrailing) + '\n'; } })(list); - for (var i = 0; i < subLists.length; ++i) { - - } } else { result = '\n<' + listType + '>\n' + processListItems(list, !!trimTrailing) + '\n'; } @@ -151,7 +147,7 @@ showdown.subParser('lists', function (text, options, globals) { text = text.replace(wholeList, function (wholeMatch, m1, list, m3) { var listType = (m3.search(/[*+-]/g) > -1) ? 'ul' : 'ol'; - return parseConsecutiveLists(list, listType); + return parseConsecutiveLists(list, listType, false); }); } diff --git a/test/issues/#299.nested-ordered-unordered-list-inconsistent-behavior.html b/test/issues/#299.nested-ordered-unordered-list-inconsistent-behavior.html new file mode 100644 index 0000000..5ce685a --- /dev/null +++ b/test/issues/#299.nested-ordered-unordered-list-inconsistent-behavior.html @@ -0,0 +1,20 @@ +
    +
  • one
  • +
+
    +
  1. two
  2. +
+

foo

+
    +
  • one + +
      +
    1. two
  • +
+

foo

+
    +
  • one + +
      +
    • two
  • +
diff --git a/test/issues/#299.nested-ordered-unordered-list-inconsistent-behavior.md b/test/issues/#299.nested-ordered-unordered-list-inconsistent-behavior.md new file mode 100644 index 0000000..54829f9 --- /dev/null +++ b/test/issues/#299.nested-ordered-unordered-list-inconsistent-behavior.md @@ -0,0 +1,12 @@ +* one +1. two + +foo + +* one + 1. two + +foo + +* one + * two \ No newline at end of file