diff --git a/notebook/static/notebook/js/mathjaxutils.js b/notebook/static/notebook/js/mathjaxutils.js index 20dbfa93e..1fc310ad9 100644 --- a/notebook/static/notebook/js/mathjaxutils.js +++ b/notebook/static/notebook/js/mathjaxutils.js @@ -113,9 +113,12 @@ define([ var hasCodeSpans = /`/.test(text), de_tilde; if (hasCodeSpans) { - text = text.replace(/~/g, "~T").replace(/(^|[^\\])(`+)([^\n]*?[^`\n])\2(?!`)/gm, function (wholematch) { + var tilde = function (wholematch) { return wholematch.replace(/\$/g, "~D"); - }); + } + text = text.replace(/~/g, "~T") + .replace(/(^|[^\\])(`+)([^\n]*?[^`\n])\2(?!`)/gm, tilde) + .replace(/^\s{0,3}(`{3,})(.|\n)*?\1/gm, tilde); de_tilde = function (text) { return text.replace(/~([TD])/g, function (wholematch, character) { return { T: "~", D: "$" }[character]; diff --git a/notebook/tests/notebook/markdown.js b/notebook/tests/notebook/markdown.js index c552ae076..202379f0a 100644 --- a/notebook/tests/notebook/markdown.js +++ b/notebook/tests/notebook/markdown.js @@ -103,6 +103,12 @@ casper.notebook_test(function () { result = '
x = 1
' md_render_test(codeblock, result, 'Markdown code block unknown language'); + codeblock = '```python\ns = "$"\nt = "$"\n```' + result = '
' + 
+             's = "$"\n' +
+             't = "$"
'; + md_render_test(codeblock, result, 'Markdown code block python'); + function mathjax_render_test(input_string, result, message){ casper.thenEvaluate(function (text){ window._test_result = null;