Left side of the main table |
-
-Nested Table
+
+Nested Table
nested table C1 |
nested table C2 |
diff --git a/packages/app-cli/tests/html_to_md/preserve_nested_tables.md b/packages/app-cli/tests/html_to_md/preserve_nested_tables.md
index f9c47f3bb..4c3d10dde 100644
--- a/packages/app-cli/tests/html_to_md/preserve_nested_tables.md
+++ b/packages/app-cli/tests/html_to_md/preserve_nested_tables.md
@@ -1 +1 @@
-Left side of the main table | Nested Tablenested table C1 | nested table C2 | nested table | nested table |
|
\ No newline at end of file
+Left side of the main table | Nested Tablenested table C1 | nested table C2 | nested table | nested table |
|
\ No newline at end of file
diff --git a/packages/turndown-plugin-gfm/src/tables.js b/packages/turndown-plugin-gfm/src/tables.js
index 9cdb10ff7..391a5fa24 100644
--- a/packages/turndown-plugin-gfm/src/tables.js
+++ b/packages/turndown-plugin-gfm/src/tables.js
@@ -74,8 +74,8 @@ rules.tableRow = {
rules.table = {
// Only convert tables that can result in valid Markdown
// Other tables are kept as HTML using `keep` (see below).
- filter: function (node) {
- return node.nodeName === 'TABLE' && !tableShouldBeHtml(node);
+ filter: function (node, options) {
+ return node.nodeName === 'TABLE' && !tableShouldBeHtml(node, options);
},
replacement: function (content, node) {
@@ -174,7 +174,7 @@ const nodeContains = (node, types) => {
return false;
}
-const tableShouldBeHtml = (tableNode, preserveNestedTables) => {
+const tableShouldBeHtml = (tableNode, options) => {
const possibleTags = [
'UL',
'OL',
@@ -193,7 +193,7 @@ const tableShouldBeHtml = (tableNode, preserveNestedTables) => {
// 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');
+ if (options.preserveNestedTables) possibleTags.push('TABLE');
return nodeContains(tableNode, 'code') ||
nodeContains(tableNode, possibleTags);
@@ -249,7 +249,7 @@ export default function tables (turndownService) {
isCodeBlock_ = turndownService.isCodeBlock;
turndownService.keep(function (node) {
- if (node.nodeName === 'TABLE' && tableShouldBeHtml(node, turndownService.options.preserveNestedTables)) return true;
+ if (node.nodeName === 'TABLE' && tableShouldBeHtml(node, turndownService.options)) return true;
return false;
});
for (var key in rules) turndownService.addRule(key, rules[key])
|