fix(subParser/tables): fix undefined error in malformed tables

Cannot read property 'trim' of undefined happens when the parser is fed a malformed table.
This happens in live previews (for instance, when using Angularjs).
This commit is contained in:
Estevão Soares dos Santos 2015-07-14 00:37:53 +01:00
parent c013e7577c
commit 6176977558
5 changed files with 2 additions and 2 deletions

BIN
dist/showdown.js vendored

Binary file not shown.

BIN
dist/showdown.js.map vendored

Binary file not shown.

BIN
dist/showdown.min.js vendored

Binary file not shown.

Binary file not shown.

View File

@ -15,7 +15,7 @@ showdown.subParser('tables', function (text, options, globals) {
if (options.tableHeaderId) {
id = ' id="' + header.replace(/ /g, '_').toLowerCase() + '"';
}
if (style.trim() === '') {
if (!style || style.trim() === '') {
style = '';
} else {
style = ' style="' + style + '"';
@ -25,7 +25,7 @@ showdown.subParser('tables', function (text, options, globals) {
tables.td = function (cell, style) {
var subText = showdown.subParser('spanGamut')(cell.trim(), options, globals);
if (style.trim() === '') {
if (!style || style.trim() === '') {
style = '';
} else {
style = ' style="' + style + '"';