Closed
Description
Initial checklist
- I read the support docs
- I read the contributing guide
- I agree to follow the code of conduct
- I searched issues and discussions and couldn’t find anything (or linked relevant results below)
Affected package
mdast-util-to-markdown: "^2.1.2"
Steps to reproduce
- Pass html that includes a
<table>
element totoMarkdown()
function htmlToMarkdown(htmlString: string) {
try {
const hast = fromHtml(htmlString, {fragment: true});
const mdast = toMdast(hast);
return toMarkdown(mdast); // <-- this line throws error
} catch (error) {
console.error('Error converting HTML to Markdown:', error);
return `Error: ${error instanceof Error ? error.message : String(error)}`;
}
}
Dependencies:
"dependencies": {
"hast-util-from-html": "^2.0.3",
"hast-util-to-mdast": "^10.1.2",
"mdast-util-to-markdown": "^2.1.2"
},
Result: toMarkdown()
throws the error:
Cannot handle unknown node
table
The README.md has a "List of extensions" sections that seems to indicate that tables should work.
[syntax-tree/mdast-util-gfm-table](https://github.com/syntax-tree/mdast-util-gfm-table) — GFM tables
But I don't see any table
element included in the list of handlers in the code:
Actual behavior
toMarkdown()
throws the error "Cannot handle unknown node table".
Expected behavior
Ideally, tables would be handled but at least update the README to remove it from the list of handlers.
Runtime
Node:22.13.1 Chrome:133.0.6943.54
Package manager
yarn:1.22.22
Operating system
MacOS: Sonoma 14.7.3
Build and bundle tools
Vite