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:
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>