Add the attribute translate="no" to the katex formula generated by rehype-katex to prevent the formulas from being recognized and translated by webpage translation tools.
npm install rehype-katex-notranslateThis package is a [unified][] ([rehype][]) plugin. It Add the attribute translate="no" to the katex formula generated by rehype-katex to prevent the formulas from being recognized and translated by webpage and browser translation tools, like Chrome translate.
- rehype-katex-notranslate
- Contents
- Install
- Usage
- License
This package is [ESM only][esm].
In Node.js (version 16+), install with [npm][]:
``sh`
npm install rehype-katex-notranslate
Generally, this plugin is usually used with [rehype-katex][rehype-katex].
Say our document is
`html`
Lift(L) can be determined by Lift
Coefficient (C_L) like the following
equation.
L = \frac{1}{2} \rho v^2 S C_L
`js
import rehypeDocument from 'rehype-document';
import rehypeKatex from 'rehype-katex';
import rehypeParse from 'rehype-parse';
import rehypeStringify from 'rehype-stringify';
import rehypeKatexNotranslate from 'rehype-katex-notranslate';
import {read, write} from 'to-vfile';
import {unified} from 'unified';
const file = await unified()
.use(rehypeParse, {fragment: true})
.use(rehypeDocument, {
// Get the latest one from:
css: 'https://cdn.jsdelivr.net/npm/katex@0.16.8/dist/katex.min.css',
})
.use(rehypeKatex)
.use(rehypeKatexNotranslate) // Use this plugin after rehype-katex
.use(rehypeStringify)
.process(await read('input.html'));
file.basename = 'output.html';
await write(file);
`
Then it will outputs with
`html`
href="https://cdn.jsdelivr.net/npm/katex@0.16.8/dist/katex.min.css"
rel="stylesheet"
/>
Lift() can be determined
by Lift Coefficient ()
like the following equation.
This plugin will add the attribute translate="no"` for every katex blocks.
[MIT][license] © [Codemetic][author]
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
[npm]: https://docs.npmjs.com/cli/install
[license]: license
[author]: https://dreams.plus
[unified]: https://github.com/unifiedjs/unified
[rehype]: https://github.com/rehypejs/rehype
[rehype-katex]: https://github.com/remarkjs/remark-math/tree/main/packages/rehype-katex