diff options
Diffstat (limited to 'server/helpers/markdown.ts')
-rw-r--r-- | server/helpers/markdown.ts | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/server/helpers/markdown.ts b/server/helpers/markdown.ts index c8fb31c8c..7c4a1a8b1 100644 --- a/server/helpers/markdown.ts +++ b/server/helpers/markdown.ts | |||
@@ -19,8 +19,21 @@ const toSafeHtml = text => { | |||
19 | return sanitizeHtml(html, SANITIZE_OPTIONS) | 19 | return sanitizeHtml(html, SANITIZE_OPTIONS) |
20 | } | 20 | } |
21 | 21 | ||
22 | const mdToPlainText = text => { | ||
23 | // Convert possible markdown (emojis, emphasis and lists) to html | ||
24 | const html = markdownIt.render(text) | ||
25 | |||
26 | // Convert to safe Html | ||
27 | const safeHtml = sanitizeHtml(html, SANITIZE_OPTIONS) | ||
28 | |||
29 | return safeHtml.replace(/<[^>]+>/g, '') | ||
30 | .replace(/\n$/, '') | ||
31 | .replace('\n', ', ') | ||
32 | } | ||
33 | |||
22 | // --------------------------------------------------------------------------- | 34 | // --------------------------------------------------------------------------- |
23 | 35 | ||
24 | export { | 36 | export { |
25 | toSafeHtml | 37 | toSafeHtml, |
38 | mdToPlainText | ||
26 | } | 39 | } |