fix: markdown表格目前还没有支持 br 换行 #160

close #160
This commit is contained in:
kangfenmao 2024-10-08 21:01:48 +08:00
parent 302d7511dc
commit 37c3a4438f
3 changed files with 58 additions and 1 deletions

View File

@ -97,6 +97,7 @@
"redux": "^5.0.1", "redux": "^5.0.1",
"redux-persist": "^6.0.0", "redux-persist": "^6.0.0",
"rehype-katex": "^7.0.0", "rehype-katex": "^7.0.0",
"rehype-raw": "^7.0.0",
"remark-gfm": "^4.0.0", "remark-gfm": "^4.0.0",
"remark-math": "^6.0.0", "remark-math": "^6.0.0",
"sass": "^1.77.2", "sass": "^1.77.2",

View File

@ -8,6 +8,7 @@ import { FC, useMemo } from 'react'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import ReactMarkdown, { Components } from 'react-markdown' import ReactMarkdown, { Components } from 'react-markdown'
import rehypeKatex from 'rehype-katex' import rehypeKatex from 'rehype-katex'
import rehypeRaw from 'rehype-raw'
import remarkGfm from 'remark-gfm' import remarkGfm from 'remark-gfm'
import remarkMath from 'remark-math' import remarkMath from 'remark-math'
@ -18,7 +19,7 @@ interface Props {
message: Message message: Message
} }
const rehypePlugins = [rehypeKatex] const rehypePlugins = [rehypeRaw, rehypeKatex]
const remarkPlugins = [remarkMath, remarkGfm] const remarkPlugins = [remarkMath, remarkGfm]
const components = { const components = {

View File

@ -2283,6 +2283,7 @@ __metadata:
redux: "npm:^5.0.1" redux: "npm:^5.0.1"
redux-persist: "npm:^6.0.0" redux-persist: "npm:^6.0.0"
rehype-katex: "npm:^7.0.0" rehype-katex: "npm:^7.0.0"
rehype-raw: "npm:^7.0.0"
remark-gfm: "npm:^4.0.0" remark-gfm: "npm:^4.0.0"
remark-math: "npm:^6.0.0" remark-math: "npm:^6.0.0"
sass: "npm:^1.77.2" sass: "npm:^1.77.2"
@ -5607,6 +5608,27 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"hast-util-raw@npm:^9.0.0":
version: 9.0.4
resolution: "hast-util-raw@npm:9.0.4"
dependencies:
"@types/hast": "npm:^3.0.0"
"@types/unist": "npm:^3.0.0"
"@ungap/structured-clone": "npm:^1.0.0"
hast-util-from-parse5: "npm:^8.0.0"
hast-util-to-parse5: "npm:^8.0.0"
html-void-elements: "npm:^3.0.0"
mdast-util-to-hast: "npm:^13.0.0"
parse5: "npm:^7.0.0"
unist-util-position: "npm:^5.0.0"
unist-util-visit: "npm:^5.0.0"
vfile: "npm:^6.0.0"
web-namespaces: "npm:^2.0.0"
zwitch: "npm:^2.0.0"
checksum: 10c0/03d0fe7ba8bd75c9ce81f829650b19b78917bbe31db70d36bf6f136842496c3474e3bb1841f2d30dafe1f6b561a89a524185492b9a93d40b131000743c0d7998
languageName: node
linkType: hard
"hast-util-to-jsx-runtime@npm:^2.0.0": "hast-util-to-jsx-runtime@npm:^2.0.0":
version: 2.3.0 version: 2.3.0
resolution: "hast-util-to-jsx-runtime@npm:2.3.0" resolution: "hast-util-to-jsx-runtime@npm:2.3.0"
@ -5630,6 +5652,21 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"hast-util-to-parse5@npm:^8.0.0":
version: 8.0.0
resolution: "hast-util-to-parse5@npm:8.0.0"
dependencies:
"@types/hast": "npm:^3.0.0"
comma-separated-tokens: "npm:^2.0.0"
devlop: "npm:^1.0.0"
property-information: "npm:^6.0.0"
space-separated-tokens: "npm:^2.0.0"
web-namespaces: "npm:^2.0.0"
zwitch: "npm:^2.0.0"
checksum: 10c0/3c0c7fba026e0c4be4675daf7277f9ff22ae6da801435f1b7104f7740de5422576f1c025023c7b3df1d0a161e13a04c6ab8f98ada96eb50adb287b537849a2bd
languageName: node
linkType: hard
"hast-util-to-text@npm:^4.0.0": "hast-util-to-text@npm:^4.0.0":
version: 4.0.2 version: 4.0.2
resolution: "hast-util-to-text@npm:4.0.2" resolution: "hast-util-to-text@npm:4.0.2"
@ -5741,6 +5778,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"html-void-elements@npm:^3.0.0":
version: 3.0.0
resolution: "html-void-elements@npm:3.0.0"
checksum: 10c0/a8b9ec5db23b7c8053876dad73a0336183e6162bf6d2677376d8b38d654fdc59ba74fdd12f8812688f7db6fad451210c91b300e472afc0909224e0a44c8610d2
languageName: node
linkType: hard
"html2canvas@npm:^1.4.1": "html2canvas@npm:^1.4.1":
version: 1.4.1 version: 1.4.1
resolution: "html2canvas@npm:1.4.1" resolution: "html2canvas@npm:1.4.1"
@ -9660,6 +9704,17 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"rehype-raw@npm:^7.0.0":
version: 7.0.0
resolution: "rehype-raw@npm:7.0.0"
dependencies:
"@types/hast": "npm:^3.0.0"
hast-util-raw: "npm:^9.0.0"
vfile: "npm:^6.0.0"
checksum: 10c0/1435b4b6640a5bc3abe3b2133885c4dbff5ef2190ef9cfe09d6a63f74dd7d7ffd0cede70603278560ccf1acbfb9da9faae4b68065a28bc5aa88ad18e40f32d52
languageName: node
linkType: hard
"remark-gfm@npm:^4.0.0": "remark-gfm@npm:^4.0.0":
version: 4.0.0 version: 4.0.0
resolution: "remark-gfm@npm:4.0.0" resolution: "remark-gfm@npm:4.0.0"