talyssonoc / react-katex

Display math in TeX with KaTeX and ReactJS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

请问,我使用react-katex组件的时候,发现如果字符串中包含中文的时候,就会报错

zuwensong opened this issue · comments

请问,我使用react-katex组件的时候,发现如果字符串中包含中文的时候,就会报错

例:
image

错误信息:
image

请问如何支持中文字符呢

@zuwensong , according to KaTeX/KaTeX#380, katex should support CJK characters.

Apparently there are still some issues. react-katex is just passing the string down to katex library. It's not responsible for parsing.

Have you tried to wrap your text into \text{}?

<BlockMath math={'\\text{你好}'} />

你好,请问解决了吗?我也想实现类似的功能

@chuxusave , I don't think so. I've mentioned workaround in my previous comment. Have you tried it?

commented

@zuwensong , according to KaTeX/KaTeX#380, katex should support CJK characters.

Apparently there are still some issues. react-katex is just passing the string down to katex library. It's not responsible for parsing.

Have you tried to wrap your text into \text{}?

<BlockMath math={'\\text{你好}'} />

Wonderful! This is the answer! Works like a charm!