test and fix: disable math inside code blocks

This commit is contained in:
Arjun Radhakrishna 2018-09-26 15:14:07 -07:00
parent 5711075f0b
commit c5bee3a29d
2 changed files with 9 additions and 2 deletions

View File

@ -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];

View File

@ -103,6 +103,10 @@ casper.notebook_test(function () {
result = '<pre><code class="cm-s-ipython language-aaaa">x = 1</code></pre>'
md_render_test(codeblock, result, 'Markdown code block unknown language');
codeblock = '```python\ns = "$"\nt = "$"\n```'
result = '<pre><code class="cm-s-ipython language-python"><span class="cm-variable">s</span> <span class="cm-operator">=</span> <span class="cm-string">"$"</span>\n<span class="cm-variable">t</span> <span class="cm-operator">=</span> <span class="cm-string">"$"</span></code></pre>\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;