-
-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
💄 style: make latex always ltr (#253)
* 🐛 fix: make latex always ltr * Update rehypePlugin.ts
- Loading branch information
Showing
2 changed files
with
20 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// katex-directive | ||
// 给 class="katex" 的节点加上 dir="ltr" 属性 | ||
import type { Node } from 'unist'; | ||
import { visit } from 'unist-util-visit'; | ||
|
||
// eslint-disable-next-line unicorn/consistent-function-scoping | ||
export const rehypeKatexDir = () => (tree: Node) => { | ||
visit(tree, 'element', (node: any) => { | ||
if (node.properties?.className?.includes('katex')) { | ||
node.properties.dir = 'ltr'; | ||
} | ||
}); | ||
}; |