summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/notebook/cells/markdown.vue
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2017-04-11 18:50:21 +0100
committerPhil Hughes <me@iamphill.com>2017-04-11 18:50:21 +0100
commit4755f6066bff2617988704e18c8c141056f1b4bd (patch)
tree7e1c58dfdc96134f7d2594bf63d2be226a98b4d7 /app/assets/javascripts/notebook/cells/markdown.vue
parent3082a1195cc0939e0aa0b48a9f59dd84152ebdad (diff)
downloadgitlab-ce-4755f6066bff2617988704e18c8c141056f1b4bd.tar.gz
Moved NotebookLab assets into repo
Moved all the notebooklab assets into the GitLab repo
Diffstat (limited to 'app/assets/javascripts/notebook/cells/markdown.vue')
-rw-r--r--app/assets/javascripts/notebook/cells/markdown.vue49
1 files changed, 49 insertions, 0 deletions
diff --git a/app/assets/javascripts/notebook/cells/markdown.vue b/app/assets/javascripts/notebook/cells/markdown.vue
new file mode 100644
index 00000000000..edbba94811e
--- /dev/null
+++ b/app/assets/javascripts/notebook/cells/markdown.vue
@@ -0,0 +1,49 @@
+<template>
+ <div class="cell text-cell">
+ <prompt />
+ <div class="markdown" v-html="markdown"></div>
+ </div>
+</template>
+
+<script>
+ /* global katex */
+ import marked from 'marked';
+ import Prompt from './prompt.vue';
+
+ export default {
+ components: {
+ prompt: Prompt,
+ },
+ props: {
+ cell: {
+ type: Object,
+ required: true,
+ },
+ },
+ computed: {
+ markdown() {
+ const regex = new RegExp('^\\$\\$(.*)\\$\\$$', 'g');
+
+ const source = this.cell.source.map((line) => {
+ const matches = regex.exec(line.trim());
+
+ // Only render use the Katex library if it is actually loaded
+ if (matches && matches.length > 0 && typeof katex !== 'undefined') {
+ return katex.renderToString(matches[1]);
+ }
+
+ return line;
+ });
+
+ return marked(source.join(''));
+ },
+ },
+ };
+</script>
+
+<style>
+.markdown .katex {
+ display: block;
+ text-align: center;
+}
+</style>