ブログで MathJax を使用できるように設定していると数式表示がとても便利になるのですが、ちょっと具合の悪い場合もあります。それは、数式に解釈できる文字列を含んだ Gist のコードを貼り付けた場合です。
例えばこのように、数式の部分が自動的に変換されて表示されます。
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
<h1>オイラーの公式</h1> | |
<p>$e^{i\theta} = \cos\theta + i\sin\theta$</p> |
これを回避するには、MathJax の ignoreClass を使用します。
以下のように MathJax.Hub.Config の設定にignoreClass: "tex2jax_ignore"
を追加すると。MathJax にレンダリングさせないクラスを設定することができます。
MathJax.Hub.Config({ ... tex2jax: { ... ignoreClass: "tex2jax_ignore" } });
コードのスクリプトを張り付ける際は、下記のようにclass="tex2jax_ignore"
のブロックで囲みます。
<div class="tex2jax_ignore"> <script src="https://gist.github.com/icm7216/8409c6e4e7332a03ef5747f7f030fd58.js"></script> </div>
これで MathJax にレンダリングされず、そのまま表示できるようになります。
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
<h1>オイラーの公式</h1> | |
<p>$e^{i\theta} = \cos\theta + i\sin\theta$</p> |
0 件のコメント :
コメントを投稿