Просмотр исходного кода

added check for undefined on text due to failing to parse tables

Stewart McKee 9 лет назад
Родитель
Сommit
6e30a48890

+ 4 - 0
src/subParsers/codeSpans.js

@@ -40,6 +40,10 @@ showdown.subParser('codeSpans', function (text, options, globals) {
    (?!`)
    /gm, function(){...});
    */
+
+  if (typeof(text) === 'undefined') {
+    text = '';
+  }
   text = text.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,
     function (wholeMatch, m1, m2, m3) {
       var c = m3;

+ 48 - 0
test/features/tables/table-without-leading-pipe.html

@@ -0,0 +1,48 @@
+
+<h3 id="stats">Stats</h3>
+
+<table>
+<thead>
+<tr>
+<th>Status</th>
+<th>AGENT1</th>
+<th>AGENT2</th>
+<th>AGENT3</th>
+<th>AGENT4</th>
+<th>AGENT5</th>
+<th>AGENT6</th>
+<th>AGENT7</th>
+<th>AGENT8</th>
+<th>AGENT9</th>
+<th>TOTAL</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td>AGENT ERROR</td>
+<td>0</td>
+<td>0</td>
+<td>0</td>
+<td>0</td>
+<td>0</td>
+<td>0</td>
+<td>0</td>
+<td>0</td>
+<td>0</td>
+<td></td>
+</tr>
+<tr>
+<td>APPROVED</td>
+<td>0</td>
+<td>0</td>
+<td>0</td>
+<td>0</td>
+<td>0</td>
+<td>0</td>
+<td>0</td>
+<td>0</td>
+<td>0</td>
+<td></td>
+</tr>
+</tbody>
+</table>

+ 8 - 0
test/features/tables/table-without-leading-pipe.md

@@ -0,0 +1,8 @@
+
+### Stats
+
+
+Status | AGENT1 | AGENT2 | AGENT3 | AGENT4 | AGENT5 | AGENT6 | AGENT7 | AGENT8 | AGENT9 | TOTAL |
+--- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
+AGENT ERROR | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
+APPROVED | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |