Created
July 4, 2016 14:05
-
-
Save junpeitsuji/8c5697eaae2c9878d6ccba8524117f69 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
// | |
// pukiwiki用 数式プラグイン (mathjax.inc.php) | |
// Copywrite 2013 Osamu Takeuchi <[email protected]> | |
// | |
// [履歴] | |
// 2013.04.08 初期リリース | |
// | |
// [インストール] | |
// ソースファイルを (pukiwiki)/plugin/mathjax.inc.php として保存 | |
// | |
// [使い方] | |
// #mathjax; として一回呼んでおくと、その後の TeX ソース内に | |
// 記述された mathjax 形式の tex ソースを maxjax で処理する | |
// ようになる | |
// | |
function plugin_mathjax_header() | |
{ | |
return <<< EOS | |
<meta http-equiv="X-UA-Compatible" CONTENT="IE=EmulateIE7" /> | |
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_HTMLorMML"></script> | |
<script type="text/x-mathjax-config"> | |
MathJax.Hub.Config({ | |
tex2jax: { | |
inlineMath: [ ['$','$'], ["\\(","\\)"] ], | |
displayMath: [ ['$$','$$'], ["\\[","\\]"] ] | |
}, | |
TeX: { | |
extensions: ["cancel.js","enclose.js","mhchem.js"], | |
Macros: { | |
C: '{\\mathbb C}', | |
R: '{\\mathbb R}', | |
Q: '{\\mathbb Q}', | |
Z: '{\\mathbb Z}', | |
diag: '\\mathop{\\mathrm{diag}}\\nolimits' | |
} | |
} | |
}); | |
</script> | |
EOS; | |
} | |
function plugin_mathjax_convert() | |
{ | |
return plugin_mathjax_inline(); | |
} | |
function plugin_mathjax_inline() | |
{ | |
$header = ""; | |
if (!defined("PLUGIN_MATHJAX_LOADED")) { | |
define("PLUGIN_MATHJAX_LOADED", "LOADED"); | |
$header = plugin_mathjax_header(); | |
} | |
$aryargs = func_get_args(); | |
$math = join(",", $aryargs); | |
$math = rtrim($math, ","); //remove extra comma at the end. | |
$math = htmlspecialchars($math); | |
if($math===""){ | |
return $header; | |
}else{ | |
return $header . "\\(\\displaystyle\\begin{split}" . $math . "\\end{split}\\)"; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment