2023-04-18 17:20:02 -04:00
|
|
|
import MarkdownIt from 'markdown-it';
|
2022-11-26 11:43:28 -05:00
|
|
|
import mdTasksLists from 'markdown-it-task-lists';
|
|
|
|
|
|
|
|
export class Markdown {
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
this.renderer = new MarkdownIt({html: true});
|
|
|
|
this.renderer.use(mdTasksLists, {label: true});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the front-end render used to convert markdown to HTML.
|
|
|
|
* @returns {MarkdownIt}
|
|
|
|
*/
|
|
|
|
getRenderer() {
|
|
|
|
return this.renderer;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert the given Markdown to HTML.
|
|
|
|
* @param {String} markdown
|
|
|
|
* @returns {String}
|
|
|
|
*/
|
|
|
|
render(markdown) {
|
|
|
|
return this.renderer.render(markdown);
|
|
|
|
}
|
|
|
|
|
2023-04-18 17:20:02 -04:00
|
|
|
}
|