aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2021-04-12 11:43:29 +0200
committerChocobozzz <chocobozzz@cpy.re>2021-04-13 15:45:09 +0200
commita073c912700e1ecda70a463f334f316dc62db7a4 (patch)
tree46dfa8d014765ef8baba9251c15485a545082f91 /server/helpers
parent84bced652cd72aad852914a4a734c47dd0002fef (diff)
downloadPeerTube-a073c912700e1ecda70a463f334f316dc62db7a4.tar.gz
PeerTube-a073c912700e1ecda70a463f334f316dc62db7a4.tar.zst
PeerTube-a073c912700e1ecda70a463f334f316dc62db7a4.zip
modify tests to support current behaviour regarding plaintext description
Diffstat (limited to 'server/helpers')
-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}