Skip to content

Instantly share code, notes, and snippets.

@hidsh
Last active February 18, 2022 00:32
Show Gist options
  • Save hidsh/2607159 to your computer and use it in GitHub Desktop.
Save hidsh/2607159 to your computer and use it in GitHub Desktop.
mathjax interactive preview
<!-- this document is fully based on MathJax-jquery.html by kurokigen. -->
<html>
<head>
<title>Live Preview of MathJax Type Setting</title>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [['$','$'], ["\\(","\\)"]] } });
</script>
<script type="text/javascript"
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.5.1.min.js"></script>
<script type="text/javascript">
$(function() {
function makePreview() {
input = $('#input').val().replace(/</g, "&lt;").replace(/>/g, "&gt;");
$('#preview').html(input);
MathJax.Hub.Queue(["Typeset",MathJax.Hub,"preview"]);
}
$('body').keyup(function(){makePreview()});
$('body').bind('updated',function(){makePreview()});
makePreview();
});
</script>
</head>
<body>
<h1>Live Preview of MathJax Type Setting</h1>
<h2>Input</h2>
<p>Examples: <code>$\varphi_i$</code>, <code>\(\dfrac12\)</code>, <code>\[\sum_{n=1}^\infty x^n\]</code>, etc</p>
<p><textarea id="input" name="body" cols="80" rows="8">\[ \zeta(s) = \sum_{n=1}^\infty\frac{1}{n^s} \]</textarea></p>
<h2>Preview Area</h2>
<div id="preview"></div>
<script type="text/javascript"><!--
var fhp_c_pc = navigator.userAgent.toLowerCase();
var fhp_ie = ((fhp_c_pc.indexOf("msie") != -1) && (fhp_c_pc.indexOf("opera") == -1));
var fhp_cs, fhp_wt, fhp_dm;
if (fhp_ie) {
fhp_cs = document.charset;
}else{
fhp_cs = document.characterSet;
}
fhp_dm = encodeURI(document.location);
fhp_wt = "";
fhp_wt = '<' + 'script src="http://web.fc2.com/header.php?cs=' + fhp_cs + '&dm=' + fhp_dm + '" charset="UTF-8"><' + '/script>';
fhp_wt += '<' + 'script src="http://web.fc2.com/footer/footer.php?cs=' + fhp_cs + '&dm=' + fhp_dm + '"><' + '/script>';
document.write(fhp_wt);
//--></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment