Skip to content

Commit 6289f94

Browse files
authored
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
1 parent 35ec4b2 commit 6289f94

File tree

5 files changed

+18
-2
lines changed

5 files changed

+18
-2
lines changed

contentlayer.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
import rehypeSlug from 'rehype-slug'
1919
import rehypeAutolinkHeadings from 'rehype-autolink-headings'
2020
import rehypeKatex from 'rehype-katex'
21+
import rehypeKatexNoTranslate from 'rehype-katex-notranslate'
2122
import rehypeCitation from 'rehype-citation'
2223
import rehypePrismPlus from 'rehype-prism-plus'
2324
import rehypePresetMinify from 'rehype-preset-minify'
@@ -169,6 +170,7 @@ export default makeSource({
169170
},
170171
],
171172
rehypeKatex,
173+
rehypeKatexNoTranslate,
172174
[rehypeCitation, { path: path.join(root, 'data') }],
173175
[rehypePrismPlus, { defaultLanguage: 'js', ignoreMissing: true }],
174176
rehypePresetMinify,

data/blog/release-of-tailwind-nextjs-starter-blog-v2.0.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,5 +186,7 @@ Using the template? Support this effort by giving a star on GitHub, sharing your
186186
[MIT](https://github.com/timlrx/tailwind-nextjs-starter-blog/blob/main/LICENSE) © [Timothy Lin](https://www.timrlx.com)
187187

188188
[^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.
189+
189190
[^2]: This is different from Next.js App Directory layouts and are best thought of as reusable React containers.
191+
190192
[^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.

faq/customize-kbar-search.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function createSearchIndex(allBlogs) {
6666
) {
6767
writeFileSync(
6868
`public/${siteMetadata.search.kbarConfig.searchDocumentsPath}`,
69-
JSON.stringify((sortPosts(allBlogs)))
69+
JSON.stringify(sortPosts(allBlogs))
7070
)
7171
console.log('Local search index generated...')
7272
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"rehype-autolink-headings": "^7.1.0",
3636
"rehype-citation": "^2.0.0",
3737
"rehype-katex": "^7.0.0",
38+
"rehype-katex-notranslate": "^1.1.4",
3839
"rehype-preset-minify": "7.0.0",
3940
"rehype-prism-plus": "^2.0.0",
4041
"rehype-slug": "^6.0.0",

yarn.lock

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10009,6 +10009,16 @@ react@rc:
1000910009
languageName: node
1001010010
linkType: hard
1001110011

10012+
"rehype-katex-notranslate@npm:^1.1.4":
10013+
version: 1.1.4
10014+
resolution: "rehype-katex-notranslate@npm:1.1.4"
10015+
dependencies:
10016+
unified: ^11.0.5
10017+
unist-util-visit: ^5.0.0
10018+
checksum: e43de356b695e0c7fa9d806f18c4447a976d0c7b9b11b7a70ac392b83566cc92622d3f73f408d3c923fcb159a5467d800db311816c436407b25208e16d27714d
10019+
languageName: node
10020+
linkType: hard
10021+
1001210022
"rehype-katex@npm:^7.0.0":
1001310023
version: 7.0.1
1001410024
resolution: "rehype-katex@npm:7.0.1"
@@ -11347,6 +11357,7 @@ react@rc:
1134711357
rehype-autolink-headings: ^7.1.0
1134811358
rehype-citation: ^2.0.0
1134911359
rehype-katex: ^7.0.0
11360+
rehype-katex-notranslate: ^1.1.4
1135011361
rehype-preset-minify: 7.0.0
1135111362
rehype-prism-plus: ^2.0.0
1135211363
rehype-slug: ^6.0.0
@@ -11721,7 +11732,7 @@ react@rc:
1172111732
languageName: node
1172211733
linkType: hard
1172311734

11724-
"unified@npm:^11.0.0, unified@npm:^11.0.4":
11735+
"unified@npm:^11.0.0, unified@npm:^11.0.4, unified@npm:^11.0.5":
1172511736
version: 11.0.5
1172611737
resolution: "unified@npm:11.0.5"
1172711738
dependencies:

0 commit comments

Comments
 (0)