Keep tables with no definitive heading row

This commit is contained in:
Dom Christie
2018-05-11 11:55:21 +01:00
parent 7eeb773b6b
commit 93d5aed1fe
2 changed files with 42 additions and 19 deletions

View File

@@ -32,7 +32,12 @@ rules.tableRow = {
}
rules.table = {
filter: 'table',
// Only convert tables with a heading row.
// Tables with no heading row are kept using `keep` (see below).
filter: function (node) {
return node.nodeName === 'TABLE' && isHeadingRow(node.rows[0])
},
replacement: function (content) {
// Ensure there are no blank lines
content = content.replace('\n\n', '\n')
@@ -85,5 +90,8 @@ function cell (content, node) {
}
export default function tables (turndownService) {
turndownService.keep(function (node) {
return node.nodeName === 'TABLE' && !isHeadingRow(node.rows[0])
})
for (var key in rules) turndownService.addRule(key, rules[key])
}