Skip to content

Commit

Permalink
Remove the contains_mathjax javascript function; instead, always call…
Browse files Browse the repository at this point in the history
… MathJax to typeset what it can.

If this ends up typesetting too much, we should probably use the MathJax tools for ignoring certain divs.
  • Loading branch information
Jason Grout committed Jan 14, 2012
1 parent 6a4eed4 commit 8d6b0a0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 37 deletions.
1 change: 0 additions & 1 deletion sagenb/data/sage/js/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ var sagenb_debug = (function debugging(options) {
// 'continue_update_check',
// 'start_update_check',
// 'cancel_update_check',
// 'contains_mathjax',
// 'set_output_text',
// 'set_input_text',
// 'CellWriter',
Expand Down
43 changes: 7 additions & 36 deletions sagenb/data/sage/js/notebook_lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -1234,12 +1234,10 @@ function update_introspection_text(id, text) {

if (intr.loaded) {
introspect_div.html(text);
if (contains_mathjax(text)) {
try {
MathJax.Hub.Queue(["Typeset",MathJax.Hub,introspect_div.get(0)]);
} catch (e) {
introspect_div.html('Error typesetting mathematics' + introspect_div.html());
}
try {
MathJax.Hub.Queue(["Typeset",MathJax.Hub,introspect_div.get(0)]);
} catch (e) {
introspect_div.html('Error typesetting mathematics' + introspect_div.html());
}

introspect_div.find('.docstring').prepend('<div class="click-message" style="cursor: pointer">' + translations["Click here to pop out"] + '</div><div class="unprinted-note">' + translations["unprinted"] + '</div>');
Expand Down Expand Up @@ -3535,25 +3533,6 @@ function cancel_update_check() {
}


function contains_mathjax(text) {
/*
Returns true if text contains some mathjax text. This function
sucks, since it really just looks for class="math" or type="math/tex" and is easy to
throw off. Fix this!
INPUT:
text -- a string
*/
// TODO: Use a RegExp.
text = text.toLowerCase();
// Mathjax - match math/tex and math/tex; mode=display
return (text.indexOf('class="math"') !== -1 ||
text.indexOf("class='math'") !== -1 ||
text.indexOf('type="math/tex') !== -1 ||
text.indexOf("type='math/tex") !== -1);
}


function set_output_text(id, status, output_text, output_text_wrapped,
output_html, introspect_html, no_interact) {
/*
Expand Down Expand Up @@ -3612,9 +3591,7 @@ function set_output_text(id, status, output_text, output_text_wrapped,

cell_interact = get_element('cell-interact-' + id);
cell_interact.innerHTML = new_interact_output;
if (contains_mathjax(new_interact_output)) {
MathJax.Hub.Queue(["Typeset",MathJax.Hub,cell_interact]);
}
MathJax.Hub.Queue(["Typeset",MathJax.Hub,cell_interact]);

return false;
}
Expand All @@ -3636,7 +3613,7 @@ function set_output_text(id, status, output_text, output_text_wrapped,
cell_output_html.innerHTML = output_html;

// Call MathJax on the final output.
if (status === 'd' && (contains_mathjax(output_text)||contains_mathjax(output_text_wrapped))) {
if (status === 'd' ) {
try {
MathJax.Hub.Queue(["Typeset",MathJax.Hub,cell_output]);
} catch (e) {
Expand All @@ -3660,13 +3637,7 @@ function set_output_text(id, status, output_text, output_text_wrapped,
if (status === 'd' && introspect_html === '' && is_interacting_cell(id)) {
// This is the first time that the underlying Python interact
// function (i.e., interact.recompute) is actually called!
if (contains_mathjax(output_text_wrapped)) {
try {
MathJax.Hub.Queue(["Typeset",MathJax.Hub,cell_output]);
} catch (e2) {
// Do nothing.
}
}
MathJax.Hub.Queue(["Typeset",MathJax.Hub,cell_output]);
return 'trigger_interact';
}

Expand Down

0 comments on commit 8d6b0a0

Please sign in to comment.