Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converting empty table with caption throws an error #17

Open
postatum opened this issue Oct 1, 2019 · 1 comment
Open

Converting empty table with caption throws an error #17

postatum opened this issue Oct 1, 2019 · 1 comment

Comments

@postatum
Copy link

postatum commented Oct 1, 2019

Hi. Thanks for a great library and plugin! 🍎

[email protected]
[email protected]

This code produces an error. Removing <caption> from <table> makes the code work fine.

const TurndownService = require('turndown')
const turndownPluginGfm = require('turndown-plugin-gfm')

const turndownService = new TurndownService()
turndownService.use(turndownPluginGfm.gfm)

console.log(turndownService.turndown(`
  <html>
    <head>
      <title></title>
    </head>
    <body>
      <h1>something</h1>
      <table>
        <caption>Foo</caption>
      </table>
    </body>
  </html>`))
/test_proj/node_modules/turndown-plugin-gfm/lib/turndown-plugin-gfm.cjs.js:100
  var parentNode = tr.parentNode;
                      ^

TypeError: Cannot read property 'parentNode' of undefined
    at isHeadingRow (/test_proj/node_modules/turndown-plugin-gfm/lib/turndown-plugin-gfm.cjs.js:100:23)
    at Object.filter (/test_proj/node_modules/turndown-plugin-gfm/lib/turndown-plugin-gfm.cjs.js:77:41)
    at filterValue (/test_proj/node_modules/turndown/lib/turndown.cjs.js:364:16)
    at findRule (/test_proj/node_modules/turndown/lib/turndown.cjs.js:352:9)
    at Rules.forNode (/test_proj/node_modules/turndown/lib/turndown.cjs.js:337:17)
    at TurndownService.replacementForNode (/test_proj/node_modules/turndown/lib/turndown.cjs.js:823:25)
    at /test_proj/node_modules/turndown/lib/turndown.cjs.js:788:40
    at Proxy.reduce (<anonymous>)
    at TurndownService.process (/test_proj/node_modules/turndown/lib/turndown.cjs.js:781:17)
    at TurndownService.turndown (/test_proj/node_modules/turndown/lib/turndown.cjs.js:693:26)
@guyplusplus
Copy link

Created pull request #31 for this bug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants