From 6e30a488901f0292264e80fe0758d4e10493c10f Mon Sep 17 00:00:00 2001 From: Stewart McKee Date: Tue, 24 May 2016 10:26:59 +0100 Subject: [PATCH] added check for undefined on text due to failing to parse tables --- src/subParsers/codeSpans.js | 4 ++ .../tables/table-without-leading-pipe.html | 48 +++++++++++++++++++ .../tables/table-without-leading-pipe.md | 8 ++++ 3 files changed, 60 insertions(+) create mode 100644 test/features/tables/table-without-leading-pipe.html create mode 100644 test/features/tables/table-without-leading-pipe.md diff --git a/src/subParsers/codeSpans.js b/src/subParsers/codeSpans.js index 0abb69a..dbd85e0 100644 --- a/src/subParsers/codeSpans.js +++ b/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; diff --git a/test/features/tables/table-without-leading-pipe.html b/test/features/tables/table-without-leading-pipe.html new file mode 100644 index 0000000..2b5dd2d --- /dev/null +++ b/test/features/tables/table-without-leading-pipe.html @@ -0,0 +1,48 @@ + +

Stats

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StatusAGENT1AGENT2AGENT3AGENT4AGENT5AGENT6AGENT7AGENT8AGENT9TOTAL
AGENT ERROR000000000
APPROVED000000000
diff --git a/test/features/tables/table-without-leading-pipe.md b/test/features/tables/table-without-leading-pipe.md new file mode 100644 index 0000000..c642428 --- /dev/null +++ b/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 |