Fixed the problem that when markdown and html are mixed, the html content cannot be rendered and displayed.

This commit is contained in:
PrinOrange
2023-12-30 14:45:55 +08:00
parent d9a073c690
commit 82abf18284
3 changed files with 129 additions and 1 deletions

126
package-lock.json generated
View File

@@ -47,6 +47,7 @@
"rehype-katex": "^6.0.3", "rehype-katex": "^6.0.3",
"rehype-mathjax": "^5.0.0", "rehype-mathjax": "^5.0.0",
"rehype-preset-minify": "^7.0.0", "rehype-preset-minify": "^7.0.0",
"rehype-raw": "^7.0.0",
"rehype-slug": "5.1", "rehype-slug": "5.1",
"remark-external-links": "^9.0.1", "remark-external-links": "^9.0.1",
"remark-gfm": "^3.0.1", "remark-gfm": "^3.0.1",
@@ -4356,6 +4357,90 @@
"resolved": "https://registry.npmmirror.com/@types/unist/-/unist-2.0.10.tgz", "resolved": "https://registry.npmmirror.com/@types/unist/-/unist-2.0.10.tgz",
"integrity": "sha512-IfYcSBWE3hLpBg8+X2SEa8LVkJdJEkT2Ese2aaLs3ptGdVtABxndrMaxuFlQ1qdFf9Q5rDvDpxI3WwgvKFAsQA==" "integrity": "sha512-IfYcSBWE3hLpBg8+X2SEa8LVkJdJEkT2Ese2aaLs3ptGdVtABxndrMaxuFlQ1qdFf9Q5rDvDpxI3WwgvKFAsQA=="
}, },
"node_modules/hast-util-raw": {
"version": "9.0.1",
"resolved": "https://registry.npmjs.org/hast-util-raw/-/hast-util-raw-9.0.1.tgz",
"integrity": "sha512-5m1gmba658Q+lO5uqL5YNGQWeh1MYWZbZmWrM5lncdcuiXuo5E2HT/CIOp0rLF8ksfSwiCVJ3twlgVRyTGThGA==",
"dependencies": {
"@types/hast": "^3.0.0",
"@types/unist": "^3.0.0",
"@ungap/structured-clone": "^1.0.0",
"hast-util-from-parse5": "^8.0.0",
"hast-util-to-parse5": "^8.0.0",
"html-void-elements": "^3.0.0",
"mdast-util-to-hast": "^13.0.0",
"parse5": "^7.0.0",
"unist-util-position": "^5.0.0",
"unist-util-visit": "^5.0.0",
"vfile": "^6.0.0",
"web-namespaces": "^2.0.0",
"zwitch": "^2.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/hast-util-raw/node_modules/hast-util-from-parse5": {
"version": "8.0.1",
"resolved": "https://registry.npmjs.org/hast-util-from-parse5/-/hast-util-from-parse5-8.0.1.tgz",
"integrity": "sha512-Er/Iixbc7IEa7r/XLtuG52zoqn/b3Xng/w6aZQ0xGVxzhw5xUFxcRqdPzP6yFi/4HBYRaifaI5fQ1RH8n0ZeOQ==",
"dependencies": {
"@types/hast": "^3.0.0",
"@types/unist": "^3.0.0",
"devlop": "^1.0.0",
"hastscript": "^8.0.0",
"property-information": "^6.0.0",
"vfile": "^6.0.0",
"vfile-location": "^5.0.0",
"web-namespaces": "^2.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/hast-util-raw/node_modules/hast-util-parse-selector": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/hast-util-parse-selector/-/hast-util-parse-selector-4.0.0.tgz",
"integrity": "sha512-wkQCkSYoOGCRKERFWcxMVMOcYE2K1AaNLU8DXS9arxnLOUEWbOXKXiJUNzEpqZ3JOKpnha3jkFrumEjVliDe7A==",
"dependencies": {
"@types/hast": "^3.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/hast-util-raw/node_modules/hastscript": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/hastscript/-/hastscript-8.0.0.tgz",
"integrity": "sha512-dMOtzCEd3ABUeSIISmrETiKuyydk1w0pa+gE/uormcTpSYuaNJPbX1NU3JLyscSLjwAQM8bWMhhIlnCqnRvDTw==",
"dependencies": {
"@types/hast": "^3.0.0",
"comma-separated-tokens": "^2.0.0",
"hast-util-parse-selector": "^4.0.0",
"property-information": "^6.0.0",
"space-separated-tokens": "^2.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/hast-util-raw/node_modules/vfile-location": {
"version": "5.0.2",
"resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-5.0.2.tgz",
"integrity": "sha512-NXPYyxyBSH7zB5U6+3uDdd6Nybz6o6/od9rk8bp9H8GR3L+cm/fC0uUTbqBmUTnMCUDslAGBOIKNfvvb+gGlDg==",
"dependencies": {
"@types/unist": "^3.0.0",
"vfile": "^6.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/hast-util-select": { "node_modules/hast-util-select": {
"version": "6.0.2", "version": "6.0.2",
"resolved": "https://registry.npmmirror.com/hast-util-select/-/hast-util-select-6.0.2.tgz", "resolved": "https://registry.npmmirror.com/hast-util-select/-/hast-util-select-6.0.2.tgz",
@@ -4437,6 +4522,24 @@
"inline-style-parser": "0.2.2" "inline-style-parser": "0.2.2"
} }
}, },
"node_modules/hast-util-to-parse5": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/hast-util-to-parse5/-/hast-util-to-parse5-8.0.0.tgz",
"integrity": "sha512-3KKrV5ZVI8if87DVSi1vDeByYrkGzg4mEfeu4alwgmmIeARiBLKCZS2uw5Gb6nU9x9Yufyj3iudm6i7nl52PFw==",
"dependencies": {
"@types/hast": "^3.0.0",
"comma-separated-tokens": "^2.0.0",
"devlop": "^1.0.0",
"property-information": "^6.0.0",
"space-separated-tokens": "^2.0.0",
"web-namespaces": "^2.0.0",
"zwitch": "^2.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/hast-util-to-string": { "node_modules/hast-util-to-string": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmmirror.com/hast-util-to-string/-/hast-util-to-string-3.0.0.tgz", "resolved": "https://registry.npmmirror.com/hast-util-to-string/-/hast-util-to-string-3.0.0.tgz",
@@ -4537,6 +4640,15 @@
"resolved": "https://registry.npmmirror.com/html-url-attributes/-/html-url-attributes-3.0.0.tgz", "resolved": "https://registry.npmmirror.com/html-url-attributes/-/html-url-attributes-3.0.0.tgz",
"integrity": "sha512-/sXbVCWayk6GDVg3ctOX6nxaVj7So40FcFAnWlWGNAB1LpYKcV5Cd10APjPjW80O7zYW2MsjBV4zZ7IZO5fVow==" "integrity": "sha512-/sXbVCWayk6GDVg3ctOX6nxaVj7So40FcFAnWlWGNAB1LpYKcV5Cd10APjPjW80O7zYW2MsjBV4zZ7IZO5fVow=="
}, },
"node_modules/html-void-elements": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/html-void-elements/-/html-void-elements-3.0.0.tgz",
"integrity": "sha512-bEqo66MRXsUGxWHV5IP0PUiAWwoEjba4VCzg0LjFJBpchPaTfyfCKTG6bc5F8ucKec3q5y6qOdGyYTSBEvhCrg==",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/http-proxy-agent": { "node_modules/http-proxy-agent": {
"version": "5.0.0", "version": "5.0.0",
"resolved": "https://registry.npmmirror.com/http-proxy-agent/-/http-proxy-agent-5.0.0.tgz", "resolved": "https://registry.npmmirror.com/http-proxy-agent/-/http-proxy-agent-5.0.0.tgz",
@@ -10051,6 +10163,20 @@
"unified": "^11.0.0" "unified": "^11.0.0"
} }
}, },
"node_modules/rehype-raw": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/rehype-raw/-/rehype-raw-7.0.0.tgz",
"integrity": "sha512-/aE8hCfKlQeA8LmyeyQvQF3eBiLRGNlfBJEvWH7ivp9sBqs7TNqBL5X3v157rM4IFETqDnIOO+z5M/biZbo9Ww==",
"dependencies": {
"@types/hast": "^3.0.0",
"hast-util-raw": "^9.0.0",
"vfile": "^6.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/rehype-remove-comments": { "node_modules/rehype-remove-comments": {
"version": "6.0.0", "version": "6.0.0",
"resolved": "https://registry.npmmirror.com/rehype-remove-comments/-/rehype-remove-comments-6.0.0.tgz", "resolved": "https://registry.npmmirror.com/rehype-remove-comments/-/rehype-remove-comments-6.0.0.tgz",

View File

@@ -62,6 +62,7 @@
"rehype-katex": "^6.0.3", "rehype-katex": "^6.0.3",
"rehype-mathjax": "^5.0.0", "rehype-mathjax": "^5.0.0",
"rehype-preset-minify": "^7.0.0", "rehype-preset-minify": "^7.0.0",
"rehype-raw": "^7.0.0",
"rehype-slug": "5.1", "rehype-slug": "5.1",
"remark-external-links": "^9.0.1", "remark-external-links": "^9.0.1",
"remark-gfm": "^3.0.1", "remark-gfm": "^3.0.1",

View File

@@ -27,6 +27,7 @@ import { renderToString } from "react-dom/server";
import rehypeAutolinkHeadings from "rehype-autolink-headings"; import rehypeAutolinkHeadings from "rehype-autolink-headings";
import rehypeKatex from "rehype-katex"; import rehypeKatex from "rehype-katex";
import rehypePresetMinify from "rehype-preset-minify"; import rehypePresetMinify from "rehype-preset-minify";
import rehypeRaw from "rehype-raw";
import rehypeSlug from "rehype-slug"; import rehypeSlug from "rehype-slug";
import externalLinks from "remark-external-links"; import externalLinks from "remark-external-links";
import remarkGfm from "remark-gfm"; import remarkGfm from "remark-gfm";
@@ -178,7 +179,7 @@ export const getStaticProps: GetStaticProps<ReaderPageProps> = async (context) =
parseFrontmatter: true, parseFrontmatter: true,
mdxOptions: { mdxOptions: {
remarkPlugins: [remarkPrism, externalLinks, remarkMath, remarkGfm], remarkPlugins: [remarkPrism, externalLinks, remarkMath, remarkGfm],
rehypePlugins: [rehypeKatex as any, rehypeAutolinkHeadings, rehypeSlug, rehypePresetMinify], rehypePlugins: [rehypeRaw, rehypeKatex as any, rehypeAutolinkHeadings, rehypeSlug, rehypePresetMinify],
format: "md", format: "md",
}, },
}); });