sepia-search-motore-di-rice.../client/src/shared/markdown-render.ts

22 lines
405 B
TypeScript
Raw Normal View History

2020-12-29 16:02:03 +01:00
import * as MarkdownIt from 'markdown-it'
const TEXT_RULES = [
'linkify',
'autolink',
'emphasis',
'link',
'newline',
'list'
]
const markdownIt = new MarkdownIt('zero', { linkify: true, breaks: true, html: false })
for (const rule of TEXT_RULES) {
markdownIt.enable(rule)
}
export function renderMarkdown(markdown: string) {
let html = markdownIt.render(markdown);
return html;
}