From c5bee3a29da17d04cba620e2acf6da4043e9fe0d Mon Sep 17 00:00:00 2001 From: Arjun Radhakrishna Date: Wed, 26 Sep 2018 15:14:07 -0700 Subject: [PATCH 1/4] test and fix: disable math inside code blocks --- notebook/static/notebook/js/mathjaxutils.js | 7 +++++-- notebook/tests/notebook/markdown.js | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) 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..cc59f5f25 100644 --- a/notebook/tests/notebook/markdown.js +++ b/notebook/tests/notebook/markdown.js @@ -103,6 +103,10 @@ casper.notebook_test(function () { result = '
x = 1
' md_render_test(codeblock, result, 'Markdown code block unknown language'); + codeblock = '```python\ns = "$"\nt = "$"\n```' + result = '
s = "$"\nt = "$"
\n'; + 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; From 6fd0a807788e53e5452fcb86ec08035edb8b1e70 Mon Sep 17 00:00:00 2001 From: Arjun Radhakrishna Date: Wed, 26 Sep 2018 15:42:59 -0700 Subject: [PATCH 2/4] Reformat long string --- notebook/tests/notebook/markdown.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/notebook/tests/notebook/markdown.js b/notebook/tests/notebook/markdown.js index cc59f5f25..9836b054b 100644 --- a/notebook/tests/notebook/markdown.js +++ b/notebook/tests/notebook/markdown.js @@ -104,7 +104,9 @@ casper.notebook_test(function () { md_render_test(codeblock, result, 'Markdown code block unknown language'); codeblock = '```python\ns = "$"\nt = "$"\n```' - result = '
s = "$"\nt = "$"
\n'; + result = '
' + 
+             's = "$"\n' +
+             't = "$"
\n'; md_render_test(codeblock, result, 'Markdown code block python'); function mathjax_render_test(input_string, result, message){ From 4395a838f68f0af8c9010ba27833529c52cbee57 Mon Sep 17 00:00:00 2001 From: Arjun Radhakrishna Date: Wed, 26 Sep 2018 16:41:25 -0700 Subject: [PATCH 3/4] From #4039: Fix test by pinning attrs to 17.4+ --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 96b32369d..e03297fdd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -46,6 +46,7 @@ before_install: tar -xzf geckodriver-v0.19.1-linux64.tar.gz -C geckodriver export PATH=$PATH:$PWD/geckodriver fi + - pip install "attrs>=17.4.0" install: - pip install --pre .[test] From 7eb6e29509fe97b8eaaf6f8baeb92e69d2999542 Mon Sep 17 00:00:00 2001 From: Arjun Radhakrishna Date: Wed, 26 Sep 2018 17:02:06 -0700 Subject: [PATCH 4/4] Fix spurious newline in expected result --- notebook/tests/notebook/markdown.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notebook/tests/notebook/markdown.js b/notebook/tests/notebook/markdown.js index 9836b054b..202379f0a 100644 --- a/notebook/tests/notebook/markdown.js +++ b/notebook/tests/notebook/markdown.js @@ -106,7 +106,7 @@ casper.notebook_test(function () { codeblock = '```python\ns = "$"\nt = "$"\n```' result = '
' + 
              's = "$"\n' +
-             't = "$"
\n'; + 't = "$"'; md_render_test(codeblock, result, 'Markdown code block python'); function mathjax_render_test(input_string, result, message){