{"id":1150,"date":"2021-05-29T20:21:30","date_gmt":"2021-05-29T20:21:30","guid":{"rendered":"https:\/\/www.ishygddt.xyz\/~blog\/?p=1150"},"modified":"2023-06-10T22:37:10","modified_gmt":"2023-06-11T03:37:10","slug":"mathjax-restrict-to-class","status":"publish","type":"post","link":"http:\/\/www.ishygddt.xyz\/~blog\/2021\/05\/mathjax-restrict-to-class","title":{"rendered":"WordPress: Restrict MathJax to a class"},"content":{"rendered":"<p>I write on a variety of topics, only some of which it's appropriate to have mathematical typesetting for. To avoid triggering a math rendering engine on unrelated use of $purious dollar sign$, while activating it when <span lang=\"x-mathjax\">$\\text{necessary}\\wedge\\text{appropriate}$<\/span>, I decided to restrict them to only <code class=\"language-html\" data-line=\"\">&lt;&hellip; lang=&quot;x-mathjax&quot;&gt;<\/code>. Here's how that's done (for v3):<\/p>\n<pre><code class=\"language-javascript\" data-line=\"\">MathJax = {\n\ttex: {\n\t\tinlineMath: [\n\t\t\t[&#039;$&#039;, &#039;$&#039;]\n\t\t]\n\t},\n\tstartup: {\n\t\telements: [&#039;:lang(&quot;x-mathjax&quot;)&#039;]\n\t}\n};<\/code><\/pre>\n<p>I also recommend adding the following CSS to the admin-area with a userstyle or something:<\/p>\n<pre><code class=\"language-css\" data-line=\"\">.mce-content-body :lang(&quot;x-mathjax&quot;) {\n\tbackground-color: peachpuff;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I write on a variety of topics, only some of which it's appropriate to have mathematical typesetting for. To avoid triggering a math rendering engine on unrelated use of $purious dollar sign$, while activating it when $\\text{necessary}\\wedge\\text{appropriate}$, I decided to restrict them to only &lt;&hellip; lang=&quot;x-mathjax&quot;&gt;. Here's how that's done (for v3): MathJax = { &hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[96],"tags":[129,128,22,62],"class_list":["post-1150","post","type-post","status-publish","format-standard","hentry","category-howto","tag-latex","tag-mathjax","tag-meta","tag-wordpress"],"_links":{"self":[{"href":"http:\/\/www.ishygddt.xyz\/~blog\/wp-json\/wp\/v2\/posts\/1150","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.ishygddt.xyz\/~blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.ishygddt.xyz\/~blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.ishygddt.xyz\/~blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.ishygddt.xyz\/~blog\/wp-json\/wp\/v2\/comments?post=1150"}],"version-history":[{"count":14,"href":"http:\/\/www.ishygddt.xyz\/~blog\/wp-json\/wp\/v2\/posts\/1150\/revisions"}],"predecessor-version":[{"id":2781,"href":"http:\/\/www.ishygddt.xyz\/~blog\/wp-json\/wp\/v2\/posts\/1150\/revisions\/2781"}],"wp:attachment":[{"href":"http:\/\/www.ishygddt.xyz\/~blog\/wp-json\/wp\/v2\/media?parent=1150"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.ishygddt.xyz\/~blog\/wp-json\/wp\/v2\/categories?post=1150"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.ishygddt.xyz\/~blog\/wp-json\/wp\/v2\/tags?post=1150"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}