summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/notebook
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2017-05-30 11:30:58 +0100
committerPhil Hughes <me@iamphill.com>2017-05-30 16:00:57 +0100
commite818195b2be798b1c60e00124a284b2e8f47bf0b (patch)
treeae0347a68114fe94cf6f0bf265f417f94900ba66 /app/assets/javascripts/notebook
parent374486fb2e1d51a059490a375d7fcd7aca4f65b8 (diff)
downloadgitlab-ce-e818195b2be798b1c60e00124a284b2e8f47bf0b.tar.gz
Fixes multi-line math in notebooks
Closes #30900
Diffstat (limited to 'app/assets/javascripts/notebook')
-rw-r--r--app/assets/javascripts/notebook/cells/markdown.vue22
1 files changed, 15 insertions, 7 deletions
diff --git a/app/assets/javascripts/notebook/cells/markdown.vue b/app/assets/javascripts/notebook/cells/markdown.vue
index 3e8240d10ec..53761c16de3 100644
--- a/app/assets/javascripts/notebook/cells/markdown.vue
+++ b/app/assets/javascripts/notebook/cells/markdown.vue
@@ -30,7 +30,7 @@
|
\\s\\$(?!\\$)
)
- (.+?)
+ ((.|\\n)+?)
(
\\s\\\\end{[a-zA-Z]+}$
|
@@ -45,15 +45,23 @@
let inline = false;
if (typeof katex !== 'undefined') {
- const katexString = text.replace(/\\/g, '\\');
- const matches = new RegExp(katexRegexString, 'gi').exec(katexString);
+ const katexString = text.replace(/&amp;/g, '&')
+ .replace(/&=&/g, '\\&=\\&')
+ .replace(/<(\/?)em>/g, '');
+ const regex = new RegExp(katexRegexString, 'gi');
+ const numberOfMatches = katexString.match(regex);
- if (matches && matches.length > 0) {
- if (matches[1].trim() === '$' && matches[3].trim() === '$') {
+ if (numberOfMatches && numberOfMatches.length !== 0) {
+ if (numberOfMatches.length > 1) {
+ let matches = regex.exec(katexString);
inline = true;
- text = `${katexString.replace(matches[0], '')} ${katex.renderToString(matches[2])}`;
+ while (matches !== null) {
+ text = `${text.replace(matches[0], katex.renderToString(matches[0].replace(/\$/g, '')))}`;
+ matches = regex.exec(katexString);
+ }
} else {
+ const matches = regex.exec(katexString);
text = katex.renderToString(matches[2]);
}
}
@@ -79,7 +87,7 @@
},
computed: {
markdown() {
- return marked(this.cell.source.join(''));
+ return marked(this.cell.source.join('').replace(/\\/g, '\\\\'));
},
},
};