ERROR Cannot handle unknown node table. What plugin do I have to use to support html tables? #174
Answered
by
ChristianMurphy
jonasfroeller
asked this question in
Q&A
-
The error I get: ERROR Cannot handle unknown node table
at Object.unknown (xxx/node_modules/.pnpm/[email protected]/node_modules/mdast-util-to-markdown/lib/index.js:118:9)
at Object.one [as handle] (xxx/node_modules/.pnpm/[email protected]/node_modules/zwitch/index.js:108:17)
at containerFlow (xxx/node_modules/.pnpm/[email protected]/node_modules/mdast-util-to-markdown/lib/util/container-flow.js:35:15)
at Object.containerFlowBound [as containerFlow] (xxx/node_modules/.pnpm/[email protected]/node_modules/mdast-util-to-markdown/lib/index.js:163:10)
at Object.root (xxx/node_modules/.pnpm/[email protected]/node_modules/mdast-util-to-markdown/lib/handle/root.js:23:13)
at Object.one [as handle] (xxx/node_modules/.pnpm/[email protected]/node_modules/zwitch/index.js:108:17)
at toMarkdown (xxx/node_modules/.pnpm/[email protected]/node_modules/mdast-util-to-markdown/lib/index.js:72:22)
at compiler (xxx/node_modules/.pnpm/[email protected]/node_modules/remark-stringify/lib/index.js:33:12)
at Function.stringify (xxx/node_modules/.pnpm/[email protected]/node_modules/unified/lib/index.js:1002:12)
at xxx/node_modules/.pnpm/[email protected]/node_modules/unified/lib/index.js:749:36 import rehypeParse from 'rehype-parse'
import rehypeRemark from 'rehype-remark'
import remarkStringify from 'remark-stringify'
import { fetch } from 'undici'
import { unified } from 'unified'
export default defineCachedEventHandler(async (event) => {
const urlToFetch = getRouterParam(event, 'url'); // encodedURIComponent
if (!urlToFetch) return sendError(event, createError({ statusCode: 400, statusMessage: 'Bad Request' }));
const decodedUrl = decodeURIComponent(urlToFetch);
const url = new URL(decodedUrl);
const response = await fetch(url)
.then(res => {
return res.text();
})
.then(async (html) => {
const file = await unified()
.use(rehypeParse)
.use(rehypeRemark)
.use(remarkStringify)
.process(html)
const md = String(file);
return md;
})
.then(md => {
return md;
})
.catch(err => {
console.error(err);
return sendError(event, createError({ statusCode: 500, statusMessage: 'Internal Server Error' }));
})
return response;
}) |
Beta Was this translation helpful? Give feedback.
Answered by
ChristianMurphy
Jul 18, 2024
Replies: 1 comment 1 reply
-
Welcome @jonasfroeller! 👋 |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
jonasfroeller
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Welcome @jonasfroeller! 👋
GFM is an extension of CommonMark, and includes tables.
It can be added through https://github.com/remarkjs/remark-gfm