From 37c3a4438fcb8054b653900fb9caa64751e81893 Mon Sep 17 00:00:00 2001 From: kangfenmao Date: Tue, 8 Oct 2024 21:01:48 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20markdown=E8=A1=A8=E6=A0=BC=E7=9B=AE?= =?UTF-8?q?=E5=89=8D=E8=BF=98=E6=B2=A1=E6=9C=89=E6=94=AF=E6=8C=81=20br=20?= =?UTF-8?q?=E6=8D=A2=E8=A1=8C=20#160?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit close #160 --- package.json | 1 + .../src/pages/home/Markdown/Markdown.tsx | 3 +- yarn.lock | 55 +++++++++++++++++++ 3 files changed, 58 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 258bf6b7..6752c74c 100644 --- a/package.json +++ b/package.json @@ -97,6 +97,7 @@ "redux": "^5.0.1", "redux-persist": "^6.0.0", "rehype-katex": "^7.0.0", + "rehype-raw": "^7.0.0", "remark-gfm": "^4.0.0", "remark-math": "^6.0.0", "sass": "^1.77.2", diff --git a/src/renderer/src/pages/home/Markdown/Markdown.tsx b/src/renderer/src/pages/home/Markdown/Markdown.tsx index 93f7afd4..a3be7212 100644 --- a/src/renderer/src/pages/home/Markdown/Markdown.tsx +++ b/src/renderer/src/pages/home/Markdown/Markdown.tsx @@ -8,6 +8,7 @@ import { FC, useMemo } from 'react' import { useTranslation } from 'react-i18next' import ReactMarkdown, { Components } from 'react-markdown' import rehypeKatex from 'rehype-katex' +import rehypeRaw from 'rehype-raw' import remarkGfm from 'remark-gfm' import remarkMath from 'remark-math' @@ -18,7 +19,7 @@ interface Props { message: Message } -const rehypePlugins = [rehypeKatex] +const rehypePlugins = [rehypeRaw, rehypeKatex] const remarkPlugins = [remarkMath, remarkGfm] const components = { diff --git a/yarn.lock b/yarn.lock index 31da9761..2c8d685a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2283,6 +2283,7 @@ __metadata: redux: "npm:^5.0.1" redux-persist: "npm:^6.0.0" rehype-katex: "npm:^7.0.0" + rehype-raw: "npm:^7.0.0" remark-gfm: "npm:^4.0.0" remark-math: "npm:^6.0.0" sass: "npm:^1.77.2" @@ -5607,6 +5608,27 @@ __metadata: languageName: node 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": version: 2.3.0 resolution: "hast-util-to-jsx-runtime@npm:2.3.0" @@ -5630,6 +5652,21 @@ __metadata: languageName: node 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": version: 4.0.2 resolution: "hast-util-to-text@npm:4.0.2" @@ -5741,6 +5778,13 @@ __metadata: languageName: node 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": version: 1.4.1 resolution: "html2canvas@npm:1.4.1" @@ -9660,6 +9704,17 @@ __metadata: languageName: node 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": version: 4.0.0 resolution: "remark-gfm@npm:4.0.0"