Browse Source

Turndown: cover table from Microsoft Excel

Le Tan 7 years ago
parent
commit
e27907e5b4
1 changed files with 4 additions and 2 deletions
  1. 4 2
      src/utils/turndown/turndown-plugin-gfm.js

+ 4 - 2
src/utils/turndown/turndown-plugin-gfm.js

@@ -90,7 +90,7 @@ rules.tableRow = {
 };
 
 rules.table = {
-  // Only convert tables with a heading row.
+  // If configs.autoHead is false, 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'
@@ -142,7 +142,9 @@ function isFirstTbody (element) {
       (
         previousSibling.nodeName === 'THEAD' &&
         /^\s*$/i.test(previousSibling.textContent)
-      )
+      ) ||
+      // For parsting table from Microsoft Excel.
+      previousSibling.nodeName == 'COLGROUP'
     )
   )
 }