feat: add rehype-katex-notranslate plugin for preventing symbols in formulas to be translated by browser translate-tools. (#1049)

* fix(format): format the codes

* fix(format): format the code

* feat: add rehype-katex-notranslate plugin to prevent symbol in formulas to be translated.

* update(dep): update `rehype-katex-notranslate` version
This commit is contained in:
秋刀鱼之愿 2024-11-03 17:01:35 +08:00 committed by GitHub
parent 35ec4b25ef
commit 6289f94e87
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 18 additions and 2 deletions

View File

@ -18,6 +18,7 @@ import {
import rehypeSlug from 'rehype-slug' import rehypeSlug from 'rehype-slug'
import rehypeAutolinkHeadings from 'rehype-autolink-headings' import rehypeAutolinkHeadings from 'rehype-autolink-headings'
import rehypeKatex from 'rehype-katex' import rehypeKatex from 'rehype-katex'
import rehypeKatexNoTranslate from 'rehype-katex-notranslate'
import rehypeCitation from 'rehype-citation' import rehypeCitation from 'rehype-citation'
import rehypePrismPlus from 'rehype-prism-plus' import rehypePrismPlus from 'rehype-prism-plus'
import rehypePresetMinify from 'rehype-preset-minify' import rehypePresetMinify from 'rehype-preset-minify'
@ -169,6 +170,7 @@ export default makeSource({
}, },
], ],
rehypeKatex, rehypeKatex,
rehypeKatexNoTranslate,
[rehypeCitation, { path: path.join(root, 'data') }], [rehypeCitation, { path: path.join(root, 'data') }],
[rehypePrismPlus, { defaultLanguage: 'js', ignoreMissing: true }], [rehypePrismPlus, { defaultLanguage: 'js', ignoreMissing: true }],
rehypePresetMinify, rehypePresetMinify,

View File

@ -186,5 +186,7 @@ Using the template? Support this effort by giving a star on GitHub, sharing your
[MIT](https://github.com/timlrx/tailwind-nextjs-starter-blog/blob/main/LICENSE) © [Timothy Lin](https://www.timrlx.com) [MIT](https://github.com/timlrx/tailwind-nextjs-starter-blog/blob/main/LICENSE) © [Timothy Lin](https://www.timrlx.com)
[^1]: The previous version injects Preact into the production build. However, this is no longer possible as it does not support React Server Components. While overall bundle size has increased to about 85kB, most of the content can be pre-rendered on the server side, resulting in a low first contentful paint and time to interactive. Using React throughtout also leads to more consistent behavior with external libraries and components. [^1]: The previous version injects Preact into the production build. However, this is no longer possible as it does not support React Server Components. While overall bundle size has increased to about 85kB, most of the content can be pre-rendered on the server side, resulting in a low first contentful paint and time to interactive. Using React throughtout also leads to more consistent behavior with external libraries and components.
[^2]: This is different from Next.js App Directory layouts and are best thought of as reusable React containers. [^2]: This is different from Next.js App Directory layouts and are best thought of as reusable React containers.
[^3]: This takes advantage of Server Components by making it simple to specify the layout of choice in the markdown file and match against the `layouts` object which is then used to render the appropriate layout component. [^3]: This takes advantage of Server Components by making it simple to specify the layout of choice in the markdown file and match against the `layouts` object which is then used to render the appropriate layout component.

View File

@ -66,7 +66,7 @@ function createSearchIndex(allBlogs) {
) { ) {
writeFileSync( writeFileSync(
`public/${siteMetadata.search.kbarConfig.searchDocumentsPath}`, `public/${siteMetadata.search.kbarConfig.searchDocumentsPath}`,
JSON.stringify((sortPosts(allBlogs))) JSON.stringify(sortPosts(allBlogs))
) )
console.log('Local search index generated...') console.log('Local search index generated...')
} }

View File

@ -35,6 +35,7 @@
"rehype-autolink-headings": "^7.1.0", "rehype-autolink-headings": "^7.1.0",
"rehype-citation": "^2.0.0", "rehype-citation": "^2.0.0",
"rehype-katex": "^7.0.0", "rehype-katex": "^7.0.0",
"rehype-katex-notranslate": "^1.1.4",
"rehype-preset-minify": "7.0.0", "rehype-preset-minify": "7.0.0",
"rehype-prism-plus": "^2.0.0", "rehype-prism-plus": "^2.0.0",
"rehype-slug": "^6.0.0", "rehype-slug": "^6.0.0",

View File

@ -10009,6 +10009,16 @@ react@rc:
languageName: node languageName: node
linkType: hard linkType: hard
"rehype-katex-notranslate@npm:^1.1.4":
version: 1.1.4
resolution: "rehype-katex-notranslate@npm:1.1.4"
dependencies:
unified: ^11.0.5
unist-util-visit: ^5.0.0
checksum: e43de356b695e0c7fa9d806f18c4447a976d0c7b9b11b7a70ac392b83566cc92622d3f73f408d3c923fcb159a5467d800db311816c436407b25208e16d27714d
languageName: node
linkType: hard
"rehype-katex@npm:^7.0.0": "rehype-katex@npm:^7.0.0":
version: 7.0.1 version: 7.0.1
resolution: "rehype-katex@npm:7.0.1" resolution: "rehype-katex@npm:7.0.1"
@ -11347,6 +11357,7 @@ react@rc:
rehype-autolink-headings: ^7.1.0 rehype-autolink-headings: ^7.1.0
rehype-citation: ^2.0.0 rehype-citation: ^2.0.0
rehype-katex: ^7.0.0 rehype-katex: ^7.0.0
rehype-katex-notranslate: ^1.1.4
rehype-preset-minify: 7.0.0 rehype-preset-minify: 7.0.0
rehype-prism-plus: ^2.0.0 rehype-prism-plus: ^2.0.0
rehype-slug: ^6.0.0 rehype-slug: ^6.0.0
@ -11721,7 +11732,7 @@ react@rc:
languageName: node languageName: node
linkType: hard linkType: hard
"unified@npm:^11.0.0, unified@npm:^11.0.4": "unified@npm:^11.0.0, unified@npm:^11.0.4, unified@npm:^11.0.5":
version: 11.0.5 version: 11.0.5
resolution: "unified@npm:11.0.5" resolution: "unified@npm:11.0.5"
dependencies: dependencies: