Upgrade to MathJax 3
This commit is contained in:
parent
6bd15ded9c
commit
710fae5fe3
6 changed files with 31 additions and 37 deletions
|
@ -36,23 +36,17 @@ $(function () {
|
||||||
success: function () {
|
success: function () {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
url: 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS_HTML',
|
url: 'https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js',
|
||||||
dataType: 'script',
|
dataType: 'script',
|
||||||
cache: true,
|
cache: true,
|
||||||
success: function () {
|
success: function () {
|
||||||
MathJax.Hub.Queue(function () {
|
MathJax.typeset();
|
||||||
$content.find('.tex-image').hide();
|
|
||||||
$content.find('.tex-text').show();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
MathJax.Hub.Queue(['Typeset', MathJax.Hub, $content[0]], function () {
|
MathJax.typeset($content[0]);
|
||||||
$content.find('.tex-image').hide();
|
|
||||||
$content.find('.tex-text').show();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,10 +1,23 @@
|
||||||
window.MathJax = {
|
window.MathJax = {
|
||||||
messageStyle: 'none',
|
options: {
|
||||||
tex2jax: {
|
ignoreHtmlClass: 'tex2jax_ignore',
|
||||||
inlineMath: [
|
processHtmlClass: 'tex2jax_process',
|
||||||
['$', '$'],
|
renderActions: {
|
||||||
['\\(', '\\)']
|
find: [10, function (doc) {
|
||||||
]
|
for (const node of document.querySelectorAll('script[type^="math/tex"]')) {
|
||||||
},
|
const display = !!node.type.match(/; *mode=display/);
|
||||||
showMathMenu: false
|
const math = new doc.options.MathItem(node.textContent, doc.inputJax[0], display);
|
||||||
|
const text = document.createTextNode('');
|
||||||
|
const sibling = node.previousElementSibling;
|
||||||
|
node.parentNode.replaceChild(text, node);
|
||||||
|
math.start = {node: text, delim: '', n: 0};
|
||||||
|
math.end = {node: text, delim: '', n: 0};
|
||||||
|
doc.math.push(math);
|
||||||
|
if (sibling && sibling.matches('.MathJax_Preview')) {
|
||||||
|
sibling.parentNode.removeChild(sibling);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, '']
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
|
@ -3,9 +3,9 @@ function mathjax_pagedown($) {
|
||||||
$.each(window.editors, function (id, editor) {
|
$.each(window.editors, function (id, editor) {
|
||||||
var preview = $('div.wmd-preview#' + id + '_wmd_preview')[0];
|
var preview = $('div.wmd-preview#' + id + '_wmd_preview')[0];
|
||||||
editor.hooks.chain('onPreviewRefresh', function () {
|
editor.hooks.chain('onPreviewRefresh', function () {
|
||||||
MathJax.Hub.Queue(["Typeset", MathJax.Hub, preview]);
|
MathJax.typeset(preview);
|
||||||
});
|
});
|
||||||
MathJax.Hub.Queue(["Typeset", MathJax.Hub, preview]);
|
MathJax.typeset(preview);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,7 +156,7 @@ let META_HEADER = [
|
||||||
$('#chat-log').append($data);
|
$('#chat-log').append($data);
|
||||||
$('#chat-box').scrollTop($('#chat-box')[0].scrollHeight);
|
$('#chat-box').scrollTop($('#chat-box')[0].scrollHeight);
|
||||||
register_time($('.time-with-rel'));
|
register_time($('.time-with-rel'));
|
||||||
MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
|
MathJax.typeset();
|
||||||
merge_authors();
|
merge_authors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ let META_HEADER = [
|
||||||
else {
|
else {
|
||||||
add_new_message(message, room, true);
|
add_new_message(message, room, true);
|
||||||
}
|
}
|
||||||
MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
|
MathJax.typeset();
|
||||||
register_time($('.time-with-rel'));
|
register_time($('.time-with-rel'));
|
||||||
remove_unread_current_user();
|
remove_unread_current_user();
|
||||||
merge_authors();
|
merge_authors();
|
||||||
|
|
|
@ -55,10 +55,7 @@
|
||||||
function update_math($comment) {
|
function update_math($comment) {
|
||||||
if ('MathJax' in window) {
|
if ('MathJax' in window) {
|
||||||
var $body = $comment.find('.comment-body');
|
var $body = $comment.find('.comment-body');
|
||||||
MathJax.Hub.Queue(['Typeset', MathJax.Hub, $body[0]], function () {
|
MathJax.typeset($body[0]);
|
||||||
$body.find('.tex-image').hide();
|
|
||||||
$body.find('.tex-text').show();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,7 +165,7 @@
|
||||||
window.DjangoPagedown.createEditor($wmd.get(0));
|
window.DjangoPagedown.createEditor($wmd.get(0));
|
||||||
if ('MathJax' in window) {
|
if ('MathJax' in window) {
|
||||||
var preview = $('.featherlight div.wmd-preview')[0];
|
var preview = $('.featherlight div.wmd-preview')[0];
|
||||||
MathJax.Hub.Queue(['Typeset', MathJax.Hub, preview]);
|
MathJax.typeset(preview);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,2 @@
|
||||||
<script type="text/javascript" src="{{ static('mathjax_config.js') }}"></script>
|
<script type="text/javascript" src="{{ static('mathjax_config.js') }}"></script>
|
||||||
<script type="text/javascript"
|
<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script>
|
||||||
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS_HTML"></script>
|
|
||||||
<script type="text/javascript">
|
|
||||||
window.reload_mathjax = function () {
|
|
||||||
MathJax.Hub.queue.Push(function () {
|
|
||||||
$('.tex-image').hide();
|
|
||||||
$('.tex-text').show();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
window.reload_mathjax();
|
|
||||||
</script>
|
|
||||||
|
|
Loading…
Reference in a new issue