Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion notebook/base/handlers.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def mathjax_url(self):

@property
def mathjax_config(self):
return self.settings.get('mathjax_config', 'TeX-AMS_HTML-full,Safe')
return self.settings.get('mathjax_config', 'TeX-AMS-MML_HTMLorMML-full,Safe')

@property
def base_url(self):
Expand Down
2 changes: 1 addition & 1 deletion notebook/notebookapp.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ def _update_mathjax_url(self, change):
else:
self.log.info("Using MathJax: %s", new)

mathjax_config = Unicode("TeX-AMS_HTML-full,Safe", config=True,
mathjax_config = Unicode("TeX-AMS-MML_HTMLorMML-full,Safe", config=True,
help="""The MathJax.js configuration file that is to be used."""
)

Expand Down
3 changes: 3 additions & 0 deletions notebook/static/notebook/js/mathjaxutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ define([
processEscapes: true,
processEnvironments: true
},
MathML: {
extensions: ['content-mathml.js']
},
// Center justify equations in code and markdown cells. Elsewhere
// we use CSS to left justify single line equations in code cells.
displayAlign: 'center',
Expand Down
24 changes: 21 additions & 3 deletions notebook/static/notebook/js/outputarea.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ define([
'text/html',
'text/markdown',
'text/latex',
'application/mathml+xml',
'image/svg+xml',
'image/png',
'image/jpeg',
Expand Down Expand Up @@ -445,7 +446,8 @@ define([
}
this._safe_append(toinsert);
// If we just output latex, typeset it.
if ((json.data['text/latex'] !== undefined) ||
if ((json.data['application/mathml+xml'] !== undefined) ||
(json.data['text/latex'] !== undefined) ||
(json.data['text/html'] !== undefined) ||
(json.data['text/markdown'] !== undefined)) {
this.typeset();
Expand Down Expand Up @@ -558,7 +560,8 @@ define([
if (this.append_mime_type(json, toinsert, handle_inserted)) {
this._safe_append(toinsert);
// If we just output latex, typeset it.
if ((json.data['text/latex'] !== undefined) ||
if ((json.data['application/mathml+xml'] !== undefined) ||
(json.data['text/latex'] !== undefined) ||
(json.data['text/html'] !== undefined) ||
(json.data['text/markdown'] !== undefined)) {
this.typeset();
Expand All @@ -570,6 +573,7 @@ define([
OutputArea.safe_outputs = {
'text/plain' : true,
'text/latex' : true,
'application/mathml+xml' : true,
'image/png' : true,
'image/jpeg' : true
};
Expand All @@ -582,7 +586,7 @@ define([
var value = json.data[type];
if (!this.trusted && !OutputArea.safe_outputs[type]) {
// not trusted, sanitize HTML
if (type==='text/html' || type==='text/svg') {
if (type==='text/html' || type==='text/svg' || type==='application/mathml+xml') {
value = security.sanitize_html(value);
} else {
// don't display if we don't know how to sanitize it
Expand Down Expand Up @@ -783,6 +787,18 @@ define([
element.append(toinsert);
return toinsert;
};

var append_mathml = function (mathml, md, element) {
/**
* This method cannot do the typesetting because the mathml first has to
* be on the page.
*/
var type = 'application/mathml+xml';
var toinsert = this.create_output_subarea(md, "output_mathml", type);
toinsert.append(mathml);
element.append(toinsert);
return toinsert;
};


OutputArea.prototype.append_raw_input = function (msg) {
Expand Down Expand Up @@ -968,6 +984,7 @@ define([
'text/html',
'text/markdown',
'text/latex',
'application/mathml+xml',
'image/svg+xml',
'image/png',
'image/jpeg',
Expand All @@ -983,6 +1000,7 @@ define([
"image/png" : append_png,
"image/jpeg" : append_jpeg,
"text/latex" : append_latex,
"application/mathml+xml" : append_mathml,
"application/javascript" : append_javascript,
"application/pdf" : append_pdf
};
Expand Down
2 changes: 1 addition & 1 deletion setupbase.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def find_package_data():
mj = lambda *path: pjoin(components, 'MathJax', *path)
static_data.extend([
mj('MathJax.js'),
mj('config', 'TeX-AMS_HTML-full.js'),
mj('config', 'TeX-AMS-MML_HTMLorMML-full.js'),
mj('config', 'Safe.js'),
])

Expand Down