]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/helpers/markdown.ts
Convert markdown to html/plain text for feeds
[github/Chocobozzz/PeerTube.git] / server / helpers / markdown.ts
index 41e57d857badfb6173f9faa56d9cad9eecdfe065..0b8c2fabce82e09689042d9e517cb6e751353826 100644 (file)
@@ -10,7 +10,7 @@ const markdownIt = new MarkdownItClass('default', { linkify: true, breaks: true,
 markdownIt.enable(TEXT_WITH_HTML_RULES)
 markdownIt.use(markdownItEmoji)
 
-const toSafeHtml = text => {
+const toSafeHtml = (text: string) => {
   if (!text) return ''
 
   // Restore line feed
@@ -23,7 +23,7 @@ const toSafeHtml = text => {
   return sanitizeHtml(html, sanitizeOptions)
 }
 
-const mdToPlainText = text => {
+const mdToPlainText = (text: string) => {
   if (!text) return ''
 
   // Convert possible markdown (emojis, emphasis and lists) to html
@@ -34,7 +34,7 @@ const mdToPlainText = text => {
 
   return safeHtml.replace(/<[^>]+>/g, '')
                  .replace(/\n$/, '')
-                 .replace('\n', ', ')
+                 .replace(/\n/g, ', ')
 }
 
 // ---------------------------------------------------------------------------