]> BookStack Code Mirror - bookstack/blob - resources/js/markdown/markdown.js
Refactored markdown editor logic
[bookstack] / resources / js / markdown / markdown.js
1 import MarkdownIt from "markdown-it";
2 import mdTasksLists from 'markdown-it-task-lists';
3
4 export class Markdown {
5
6     constructor() {
7         this.renderer = new MarkdownIt({html: true});
8         this.renderer.use(mdTasksLists, {label: true});
9     }
10
11     /**
12      * Get the front-end render used to convert markdown to HTML.
13      * @returns {MarkdownIt}
14      */
15     getRenderer() {
16         return this.renderer;
17     }
18
19     /**
20      * Convert the given Markdown to HTML.
21      * @param {String} markdown
22      * @returns {String}
23      */
24     render(markdown) {
25         return this.renderer.render(markdown);
26     }
27 }
28
29
30