Skip to content

Commit 8d1ca24

Browse files
authored
fix: html table to markdown error (#1288)
* fix: html-table-to-markdown-error * chore: auto-fix linting and formatting issues --------- Co-authored-by: ericyzhu <ericyzhu@users.noreply.github.com>
1 parent e81245e commit 8d1ca24

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

apps/renderer/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
"lethargy": "1.0.9",
6565
"lodash-es": "4.17.21",
6666
"masonic": "4.0.1",
67+
"mdast-util-gfm-table": "^2.0.0",
6768
"mdast-util-to-markdown": "^2.1.0",
6869
"nanoid": "5.0.7",
6970
"ofetch": "1.4.1",

apps/renderer/src/lib/parse-html.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type { Components } from "hast-util-to-jsx-runtime"
66
import { toJsxRuntime } from "hast-util-to-jsx-runtime"
77
import { toMdast } from "hast-util-to-mdast"
88
import { toText } from "hast-util-to-text"
9+
import { gfmTableToMarkdown } from "mdast-util-gfm-table"
910
import { toMarkdown } from "mdast-util-to-markdown"
1011
import { createElement } from "react"
1112
import { Fragment, jsx, jsxs } from "react/jsx-runtime"
@@ -237,7 +238,7 @@ export const parseHtml = (
237238
},
238239
}),
239240
toText: () => toText(hastTree),
240-
toMarkdown: () => toMarkdown(toMdast(hastTree)),
241+
toMarkdown: () => toMarkdown(toMdast(hastTree), { extensions: [gfmTableToMarkdown()] }),
241242
}
242243
}
243244

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)