Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-05-20 17:34:42 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-05-20 17:34:42 +0300
commit9f46488805e86b1bc341ea1620b866016c2ce5ed (patch)
treef9748c7e287041e37d6da49e0a29c9511dc34768 /app/assets/javascripts/notebook
parentdfc92d081ea0332d69c8aca2f0e745cb48ae5e6d (diff)
Add latest changes from gitlab-org/gitlab@13-0-stable-ee
Diffstat (limited to 'app/assets/javascripts/notebook')
-rw-r--r--app/assets/javascripts/notebook/cells/markdown.vue34
-rw-r--r--app/assets/javascripts/notebook/cells/output/index.vue3
2 files changed, 28 insertions, 9 deletions
diff --git a/app/assets/javascripts/notebook/cells/markdown.vue b/app/assets/javascripts/notebook/cells/markdown.vue
index dab27cf8269..fcb09ea90db 100644
--- a/app/assets/javascripts/notebook/cells/markdown.vue
+++ b/app/assets/javascripts/notebook/cells/markdown.vue
@@ -36,9 +36,9 @@ const katexRegexString = `(
.replace(/\s/g, '')
.trim();
-renderer.paragraph = t => {
+function renderKatex(t) {
let text = t;
- let inline = false;
+ let numInline = 0; // number of successfull converted math formulas
if (typeof katex !== 'undefined') {
const katexString = text
@@ -50,24 +50,40 @@ renderer.paragraph = t => {
const numberOfMatches = katexString.match(regex);
if (numberOfMatches && numberOfMatches.length !== 0) {
+ let matches = regex.exec(katexString);
if (matchLocation > 0) {
- let matches = regex.exec(katexString);
- inline = true;
+ numInline += 1;
while (matches !== null) {
- const renderedKatex = katex.renderToString(matches[0].replace(/\$/g, ''));
- text = `${text.replace(matches[0], ` ${renderedKatex}`)}`;
+ try {
+ const renderedKatex = katex.renderToString(
+ matches[0].replace(/\$/g, '').replace(/&#39;/g, "'"),
+ ); // get the tick ' back again from HTMLified string
+ text = `${text.replace(matches[0], ` ${renderedKatex}`)}`;
+ } catch {
+ numInline -= 1;
+ }
matches = regex.exec(katexString);
}
} else {
- const matches = regex.exec(katexString);
- text = katex.renderToString(matches[2]);
+ try {
+ text = katex.renderToString(matches[2].replace(/&#39;/g, "'"));
+ } catch (error) {
+ numInline -= 1;
+ }
}
}
}
-
+ return [text, numInline > 0];
+}
+renderer.paragraph = t => {
+ const [text, inline] = renderKatex(t);
return `<p class="${inline ? 'inline-katex' : ''}">${text}</p>`;
};
+renderer.listitem = t => {
+ const [text, inline] = renderKatex(t);
+ return `<li class="${inline ? 'inline-katex' : ''}">${text}</li>`;
+};
marked.setOptions({
renderer,
diff --git a/app/assets/javascripts/notebook/cells/output/index.vue b/app/assets/javascripts/notebook/cells/output/index.vue
index 61626f7aaf5..f2d3796cccf 100644
--- a/app/assets/javascripts/notebook/cells/output/index.vue
+++ b/app/assets/javascripts/notebook/cells/output/index.vue
@@ -63,6 +63,9 @@ export default {
},
rawCode(output) {
if (output.text) {
+ if (typeof output.text === 'string') {
+ return output.text;
+ }
return output.text.join('');
}