2023-01-30 02:38:45 +01:00
|
|
|
import micromark from 'micromark'
|
|
|
|
import striptags from 'striptags'
|
|
|
|
|
2023-09-28 02:50:43 +02:00
|
|
|
/**
|
|
|
|
* @param {string} doc
|
|
|
|
* @param {boolean} [stripTags]
|
|
|
|
* @returns
|
|
|
|
*/
|
2023-01-30 02:38:45 +01:00
|
|
|
export default function markdown(doc, stripTags = false) {
|
2023-09-28 02:50:43 +02:00
|
|
|
// @ts-expect-error missing micromark types
|
|
|
|
const html = /** @type {string} */ (micromark(doc))
|
2023-01-30 02:38:45 +01:00
|
|
|
return stripTags ? striptags(html) : html
|
|
|
|
}
|