aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2017-05-24 23:07:33 +0100
committerMichael Williamson <mike@zwobble.org>2017-05-24 23:07:33 +0100
commit9cc065c434b00b10ba234afa952fedf7e20a59af (patch)
tree86acdfaa583e5e25c7d3a6446aaa981b81681f75
parent4c90a1ca64509d6c7b5d51826ab36db1c49bb380 (diff)
Handle unexpected children in table
-rw-r--r--lib/document-to-html.js2
-rw-r--r--test/document-to-html.tests.js12
2 files changed, 13 insertions, 1 deletions
diff --git a/lib/document-to-html.js b/lib/document-to-html.js
index 48a7e61..93f9524 100644
--- a/lib/document-to-html.js
+++ b/lib/document-to-html.js
@@ -218,7 +218,7 @@ function DocumentConversion(options, comments) {
function convertTable(element, messages, options) {
var bodyIndex = _.findIndex(element.children, function(child) {
- return !child.isHeader;
+ return !child.type === documents.types.tableRow || !child.isHeader;
});
if (bodyIndex === -1) {
bodyIndex = element.children.length;
diff --git a/test/document-to-html.tests.js b/test/document-to-html.tests.js
index baa7df9..a55f9a2 100644
--- a/test/document-to-html.tests.js
+++ b/test/document-to-html.tests.js
@@ -415,6 +415,18 @@ test('tbody is omitted if all rows are headers', function() {
});
});
+test('unexpected table children do not cause error', function() {
+ var table = new documents.Table([
+ new documents.tab()
+ ]);
+ var converter = new DocumentConverter();
+
+ return converter.convertToHtml(table).then(function(result) {
+ var expectedHtml = "<table>\t</table>";
+ assert.equal(result.value, expectedHtml);
+ });
+});
+
test('empty cells are preserved in table', function() {
var table = new documents.Table([
new documents.TableRow([