mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-24 12:05:22 +08:00
test and fix: disable math inside code blocks
This commit is contained in:
parent
5711075f0b
commit
c5bee3a29d
@ -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];
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user