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