@joplin/turndown-plugin-gfm
Advanced tools
Comparing version 1.0.53 to 1.0.54
@@ -216,16 +216,25 @@ 'use strict'; | ||
const tableShouldBeHtml = (tableNode) => { | ||
const tableShouldBeHtml = (tableNode, preserveNestedTables) => { | ||
const possibleTags = [ | ||
'UL', | ||
'OL', | ||
'H1', | ||
'H2', | ||
'H3', | ||
'H4', | ||
'H5', | ||
'H6', | ||
'HR', | ||
'BLOCKQUOTE', | ||
]; | ||
// In general we should leave as HTML tables that include other tables. The | ||
// exception is with the Web Clipper when we import a web page with a layout | ||
// that's made of HTML tables. In that case we have this logic of removing the | ||
// outer table and keeping only the inner ones. For the Rich Text editor | ||
// however we always want to keep nested tables. | ||
if (preserveNestedTables) possibleTags.push('TABLE'); | ||
return nodeContains(tableNode, 'code') || | ||
nodeContains(tableNode, [ | ||
'UL', | ||
'OL', | ||
'H1', | ||
'H2', | ||
'H3', | ||
'H4', | ||
'H5', | ||
'H6', | ||
'HR', | ||
'BLOCKQUOTE', | ||
]); | ||
nodeContains(tableNode, possibleTags); | ||
}; | ||
@@ -283,3 +292,3 @@ | ||
turndownService.keep(function (node) { | ||
if (node.nodeName === 'TABLE' && tableShouldBeHtml(node)) return true; | ||
if (node.nodeName === 'TABLE' && tableShouldBeHtml(node, turndownService.options.preserveNestedTables)) return true; | ||
return false; | ||
@@ -286,0 +295,0 @@ }); |
@@ -7,3 +7,3 @@ { | ||
}, | ||
"version": "1.0.53", | ||
"version": "1.0.54", | ||
"author": "Dom Christie", | ||
@@ -45,3 +45,3 @@ "main": "lib/turndown-plugin-gfm.cjs.js", | ||
}, | ||
"gitHead": "9ac03ec33a064da623d955f6ad590060a6e2a003" | ||
"gitHead": "7c24a2f4bead520b5782cdc08635c104eedffa81" | ||
} |
13620
273