aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/markdown.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/markdown.ts')
-rw-r--r--server/helpers/markdown.ts15
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
22const 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
24export { 36export {
25 toSafeHtml 37 toSafeHtml,
38 mdToPlainText
26} 39}