Browse Source

fix(tables): fix table heading separators requiring 3 dashes instead of 2

Closes #256
Estevão Soares dos Santos 9 years ago
parent
commit
ddaacfc41a

+ 7 - 7
dist/showdown.js

@@ -1,4 +1,4 @@
-;/*! showdown 20-03-2016 */
+;/*! showdown 17-05-2016 */
 (function(){
 /**
  * Created by Tivie on 13-07-2015.
@@ -2011,7 +2011,7 @@ showdown.subParser('lists', function (text, options, globals) {
     // attacklab: add sentinel to emulate \z
     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));
 
     listStr = listStr.replace(rgx, function (wholeMatch, m1, m2, m3, m4, taskbtn, checked) {
@@ -2022,7 +2022,7 @@ showdown.subParser('lists', function (text, options, globals) {
       // Support for github tasklists
       if (taskbtn && options.tasklists) {
         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;"';
           if (checked) {
             otp += ' checked';
@@ -2362,14 +2362,14 @@ showdown.subParser('tables', function (text, options, globals) {
     return text;
   }
 
-  var tableRgx = /^[ \t]{0,3}\|?.+\|.+\n[ \t]{0,3}\|?[ \t]*:?[ \t]*(?:-|=){3,}[ \t]*:?[ \t]*\|[ \t]*:?[ \t]*(?:-|=){3,}[^]+?(?:\n\n|~0)/gm;
+  var tableRgx = /^[ \t]{0,3}\|?.+\|.+\n[ \t]{0,3}\|?[ \t]*:?[ \t]*(?:-|=){2,}[ \t]*:?[ \t]*\|[ \t]*:?[ \t]*(?:-|=){2,}[^]+?(?:\n\n|~0)/gm;
 
   function parseStyles(sLine) {
-    if (/^:[ \t]*---*$/.test(sLine)) {
+    if (/^:[ \t]*--*$/.test(sLine)) {
       return ' style="text-align:left;"';
-    } else if (/^---*[ \t]*:[ \t]*$/.test(sLine)) {
+    } else if (/^--*[ \t]*:[ \t]*$/.test(sLine)) {
       return ' style="text-align:right;"';
-    } else if (/^:[ \t]*---*[ \t]*:$/.test(sLine)) {
+    } else if (/^:[ \t]*--*[ \t]*:$/.test(sLine)) {
       return ' style="text-align:center;"';
     } else {
       return '';

File diff suppressed because it is too large
+ 0 - 0
dist/showdown.js.map


File diff suppressed because it is too large
+ 1 - 1
dist/showdown.min.js


File diff suppressed because it is too large
+ 0 - 0
dist/showdown.min.js.map


+ 4 - 4
src/subParsers/tables.js

@@ -5,14 +5,14 @@ showdown.subParser('tables', function (text, options, globals) {
     return text;
   }
 
-  var tableRgx = /^[ \t]{0,3}\|?.+\|.+\n[ \t]{0,3}\|?[ \t]*:?[ \t]*(?:-|=){3,}[ \t]*:?[ \t]*\|[ \t]*:?[ \t]*(?:-|=){3,}[^]+?(?:\n\n|~0)/gm;
+  var tableRgx = /^[ \t]{0,3}\|?.+\|.+\n[ \t]{0,3}\|?[ \t]*:?[ \t]*(?:-|=){2,}[ \t]*:?[ \t]*\|[ \t]*:?[ \t]*(?:-|=){2,}[^]+?(?:\n\n|~0)/gm;
 
   function parseStyles(sLine) {
-    if (/^:[ \t]*---*$/.test(sLine)) {
+    if (/^:[ \t]*--*$/.test(sLine)) {
       return ' style="text-align:left;"';
-    } else if (/^---*[ \t]*:[ \t]*$/.test(sLine)) {
+    } else if (/^--*[ \t]*:[ \t]*$/.test(sLine)) {
       return ' style="text-align:right;"';
-    } else if (/^:[ \t]*---*[ \t]*:$/.test(sLine)) {
+    } else if (/^:[ \t]*--*[ \t]*:$/.test(sLine)) {
       return ' style="text-align:center;"';
     } else {
       return '';

+ 14 - 0
test/features/tables/#256.table-header-separators-should-not-require-3-dashes.html

@@ -0,0 +1,14 @@
+<table>
+    <thead>
+    <tr>
+        <th>key</th>
+        <th>value</th>
+    </tr>
+    </thead>
+    <tbody>
+    <tr>
+        <td>My Key</td>
+        <td>My Value</td>
+    </tr>
+    </tbody>
+</table>

+ 3 - 0
test/features/tables/#256.table-header-separators-should-not-require-3-dashes.md

@@ -0,0 +1,3 @@
+|key|value|
+|--|--| 
+|My Key|My Value|

Some files were not shown because too many files changed in this diff