浏览代码

Merge pull request #251 from samb0t/case-insensitive-checkboxes

Support for case-insensitive checkboxes for render. [x] == [X]
Estevão Soares dos Santos 9 年之前
父节点
当前提交
478a0e4fca
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      src/subParsers/lists.js

+ 2 - 2
src/subParsers/lists.js

@@ -41,7 +41,7 @@ showdown.subParser('lists', function (text, options, globals) {
     // attacklab: add sentinel to emulate \z
     // attacklab: add sentinel to emulate \z
     listStr += '~0';
     listStr += '~0';
 
 
-    var rgx = /(\n)?(^[ \t]*)([*+-]|\d+[.])[ \t]+((\[(x| )?])?[ \t]*[^\r]+?(\n{1,2}))(?=\n*(~0|\2([*+-]|\d+[.])[ \t]+))/gm,
+    var rgx = /(\n)?(^[ \t]*)([*+-]|\d+[.])[ \t]+((\[(x|X| )?])?[ \t]*[^\r]+?(\n{1,2}))(?=\n*(~0|\2([*+-]|\d+[.])[ \t]+))/gm,
         isParagraphed = (/\n[ \t]*\n(?!~0)/.test(listStr));
         isParagraphed = (/\n[ \t]*\n(?!~0)/.test(listStr));
 
 
     listStr = listStr.replace(rgx, function (wholeMatch, m1, m2, m3, m4, taskbtn, checked) {
     listStr = listStr.replace(rgx, function (wholeMatch, m1, m2, m3, m4, taskbtn, checked) {
@@ -52,7 +52,7 @@ showdown.subParser('lists', function (text, options, globals) {
       // Support for github tasklists
       // Support for github tasklists
       if (taskbtn && options.tasklists) {
       if (taskbtn && options.tasklists) {
         bulletStyle = ' class="task-list-item" style="list-style-type: none;"';
         bulletStyle = ' class="task-list-item" style="list-style-type: none;"';
-        item = item.replace(/^[ \t]*\[(x| )?]/m, function () {
+        item = item.replace(/^[ \t]*\[(x|X| )?]/m, function () {
           var otp = '<input type="checkbox" disabled style="margin: 0px 0.35em 0.25em -1.6em; vertical-align: middle;"';
           var otp = '<input type="checkbox" disabled style="margin: 0px 0.35em 0.25em -1.6em; vertical-align: middle;"';
           if (checked) {
           if (checked) {
             otp += ' checked';
             otp += ' checked';