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

latex.vue « output « cells « notebook « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: db9e61dce82cc7b0217b2f95ca2506809f8ae02b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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>