-
-
Notifications
You must be signed in to change notification settings - Fork 141
Open
Description
Description
When using sitefetch to fetch content from the Cobblemon wiki, the process fails with a TypeError related to the TurnDown plugin that converts HTML to Markdown. The error occurs when trying to access the parentNode property of an undefined element, specifically in the GFM (GitHub Flavored Markdown) tables plugin.
Steps to Reproduce
- Install sitefetch globally:
bunx -g sitefetch - Run the command:
sitefetch https://wiki.cobblemon.com/index.php/Main_Page -o site.txt
Error Message
INFO Fetching https://wiki.cobblemon.com/index.php/PC
INFO Fetching https://wiki.cobblemon.com/index.php/Resurrection_Machine
INFO Fetching https://wiki.cobblemon.com/index.php/Tumblestone_Block_Set
INFO Fetching https://wiki.cobblemon.com/index.php/Special:WhatLinksHere/Category:Addon_Creation
INFO Fetching https://wiki.cobblemon.com/index.php/Template:Addon_Creation
/Users/name/node_modules/turndown-plugin-gfm/lib/turndown-plugin-gfm.cjs.js:100
var parentNode = tr.parentNode;
^
TypeError: Cannot read properties of undefined (reading 'parentNode')
at isHeadingRow (/Users/name/node_modules/turndown-plugin-gfm/lib/turndown-plugin-gfm.cjs.js:100:23)
at Object.filter (/Users/name/node_modules/turndown-plugin-gfm/lib/turndown-plugin-gfm.cjs.js:77:41)
at filterValue (/Users/name/node_modules/sitefetch/node_modules/turndown/lib/turndown.cjs.js:417:16)
at findRule (/Users/name/node_modules/sitefetch/node_modules/turndown/lib/turndown.cjs.js:405:9)
at Rules.forNode (/Users/name/node_modules/sitefetch/node_modules/turndown/lib/turndown.cjs.js:390:17)
at TurndownService.replacementForNode (/Users/name/node_modules/sitefetch/node_modules/turndown/lib/turndown.cjs.js:899:25)
at /Users/name/node_modules/sitefetch/node_modules/turndown/lib/turndown.cjs.js:864:40
at NodeList.reduce (<anonymous>)
at TurndownService.process (/Users/name/node_modules/sitefetch/node_modules/turndown/lib/turndown.cjs.js:857:17)
at TurndownService.replacementForNode (/Users/name/node_modules/sitefetch/node_modules/turndown/lib/turndown.cjs.js:900:25)
Environment
- OS: macOS
- Node.js: v20.17.0
- Installation method: bunx -g sitefetch
Possible Cause
The error appears to be in the TurnDown GFM plugin which is attempting to process a table element (tr) that doesn't have a parent node. This could be due to malformed HTML in the wiki or an edge case in the DOM parsing.
Possible Solutions
- Add a null check before accessing
tr.parentNodein the turndown-plugin-gfm library - Consider adding an option to disable table processing for sites with problematic table structures
- Implement a try/catch around table processing to gracefully handle these errors
Additional Notes
I was able to successfully use sitefetch with other websites, so this seems specific to the structure of the Cobblemon wiki pages.
Metadata
Metadata
Assignees
Labels
No labels