-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslide.js
36 lines (32 loc) · 938 Bytes
/
slide.js
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
const MarkdownIt = window.markdownit;
const markdownItAttrs = window.markdownItAttrs;
const hljs = window.hljs;
export default {
props:['value'],
created() {
const md = new MarkdownIt({
html: true,
linkify: true,
typographer: true,
highlight: function (str, lang) {
if (lang && hljs.getLanguage(lang)) {
try {
return '<pre class="hljs '+ lang +'"><code>' +
hljs.highlight(lang, str, true).value +
'</code></pre>';
} catch (__) {}
}
return '<pre class="hljs"><code>' + md.utils.escapeHtml(str) + '</code></pre>';
}
});
md.use(markdownItAttrs, {
leftDelimiter: '{',
rightDelimiter: '}',
allowedAttributes: []
});
this.contentHtml = md.render(this.value.content);
},
template: `
<section :class="['slide', value.class]" v-html="contentHtml"></section>
`
}