2014-09-23 20:17:05 +02:00
|
|
|
/*
|
|
|
|
* katex-enable.js - LaTeX support
|
|
|
|
*
|
|
|
|
* Copyright (c) 2014 Fredrick Brennan <admin@8chan.co>
|
|
|
|
*
|
|
|
|
* Usage:
|
|
|
|
* $config['additional_javascript'][] = 'js/jquery.min.js';
|
|
|
|
* $config['additional_javascript'][] = 'js/katex-enable.js';
|
|
|
|
*/
|
2014-10-18 22:18:04 +02:00
|
|
|
/*
|
2014-09-23 20:17:05 +02:00
|
|
|
function render_katex(el) {
|
|
|
|
try {
|
|
|
|
katex.render($(el).text(), el)
|
|
|
|
} catch (e) {
|
|
|
|
$(el).text(_('Error: Invalid LaTeX syntax.')).css('color','red');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (active_page == 'thread' || active_page == 'index') {
|
|
|
|
$(document).ready(function(){
|
|
|
|
var katex_enable = function() {
|
|
|
|
$('.tex').each(function(k, v) {
|
|
|
|
render_katex(v);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
katex_enable();
|
|
|
|
|
|
|
|
$(document).on('new_post', function(e, post) {
|
|
|
|
$(post).find('.tex').each(function(k, v) {
|
|
|
|
render_katex(v);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2014-10-18 22:18:04 +02:00
|
|
|
*/
|