summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/notebook/cells/output/latex.vue
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2021-01-20 13:34:23 -0600
committerRobert Speicher <rspeicher@gmail.com>2021-01-20 13:34:23 -0600
commit6438df3a1e0fb944485cebf07976160184697d72 (patch)
tree00b09bfd170e77ae9391b1a2f5a93ef6839f2597 /app/assets/javascripts/notebook/cells/output/latex.vue
parent42bcd54d971da7ef2854b896a7b34f4ef8601067 (diff)
downloadgitlab-ce-6438df3a1e0fb944485cebf07976160184697d72.tar.gz
Add latest changes from gitlab-org/gitlab@13-8-stable-eev13.8.0-rc42
Diffstat (limited to 'app/assets/javascripts/notebook/cells/output/latex.vue')
-rw-r--r--app/assets/javascripts/notebook/cells/output/latex.vue45
1 files changed, 45 insertions, 0 deletions
diff --git a/app/assets/javascripts/notebook/cells/output/latex.vue b/app/assets/javascripts/notebook/cells/output/latex.vue
new file mode 100644
index 00000000000..db9e61dce82
--- /dev/null
+++ b/app/assets/javascripts/notebook/cells/output/latex.vue
@@ -0,0 +1,45 @@
+<script>
+import 'mathjax/es5/tex-svg';
+import Prompt from '../prompt.vue';
+
+export default {
+ name: 'LatexOutput',
+ components: {
+ Prompt,
+ },
+ props: {
+ count: {
+ type: Number,
+ required: true,
+ },
+ rawCode: {
+ type: String,
+ required: true,
+ },
+ index: {
+ type: Number,
+ required: true,
+ },
+ },
+ computed: {
+ code() {
+ // MathJax will not parse out the inline delimeters "$$" correctly
+ // so we remove them from the raw code itself
+ const parsedCode = this.rawCode.replace(/\$\$/g, '');
+ const svg = window.MathJax.tex2svg(parsedCode);
+
+ // NOTE: This is used with `v-html` and not `v-safe-html` due to an
+ // issue with dompurify stripping out xlink attributes from use tags
+ return svg.outerHTML;
+ },
+ },
+};
+</script>
+
+<template>
+ <div class="output">
+ <prompt type="Out" :count="count" :show-output="index === 0" />
+ <!-- eslint-disable -->
+ <div ref="maths" v-html="code"></div>
+ </div>
+</template>