mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-06-03 12:34:40 +00:00
19 lines
378 B
JavaScript
19 lines
378 B
JavaScript
import MarkdownIt from 'markdown-it'
|
|
|
|
const md = new MarkdownIt({
|
|
html: false,
|
|
linkify: true,
|
|
breaks: true
|
|
})
|
|
|
|
export function renderMarkdown(text) {
|
|
return md.render(text || '')
|
|
}
|
|
|
|
export function stripMarkdown(text) {
|
|
const html = md.render(text || '')
|
|
const el = document.createElement('div')
|
|
el.innerHTML = html
|
|
return el.textContent || el.innerText || ''
|
|
}
|