mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-23 22:50:51 +08:00
12 lines
296 B
JavaScript
12 lines
296 B
JavaScript
export function stripMarkdown(text) {
|
|
return text ? text.replace(/[#_*`>\-\[\]\(\)!]/g, '') : ''
|
|
}
|
|
|
|
export function stripMarkdownLength(text, length) {
|
|
const plain = stripMarkdown(text)
|
|
if (!length || plain.length <= length) {
|
|
return plain
|
|
}
|
|
return plain.slice(0, length) + '...'
|
|
}
|