最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Can MathJax be made to only convert LaTeX if it's inside a certain tag? - Stack Overflow

programmeradmin2浏览0评论

I have a text editor in which a user can write HTML code. I don't want them to write LaTeX outside of a particular element. It might be something like:

<x-latexmath>...</x-latexmath>

I want it so if they have LaTeX math outside of that tag, it's just displayed as normal text. How might this be possible?

I have a text editor in which a user can write HTML code. I don't want them to write LaTeX outside of a particular element. It might be something like:

<x-latexmath>...</x-latexmath>

I want it so if they have LaTeX math outside of that tag, it's just displayed as normal text. How might this be possible?

Share Improve this question asked Jul 1, 2012 at 22:11 Phlox MidasPhlox Midas 4,3694 gold badges40 silver badges58 bronze badges 1
  • 3 elements: mathjax/docs/2.0/options/hub.html – mu is too short Commented Jul 1, 2012 at 22:25
Add a ment  | 

1 Answer 1

Reset to default 11

MathJax doesn't have a way to use user-defined tags to trigger math processing, but you can use MathJax's tex2jax preprocessor's processClass and ignoreClass parameters to allow you to control which parts of the page to process. See the text2jax configuration for details, but the idea would be to use

<body class="tex2jax_ignore">
...
<span class="tex2jax_process">...</span>
...
</body>

so that the main part of the page isn't processed, and only the span's (or div's if you prefer) containing the mathematics will be processed by MathJax.

发布评论

评论列表(0)

  1. 暂无评论