]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/videos/shared/markdown.service.ts
Handle markdown in account/video channel pages
[github/Chocobozzz/PeerTube.git] / client / src / app / videos / shared / markdown.service.ts
index dd8ff20d83181b635eaf4c2725e9c272b11de6d3..14eeba77750c85acc5aa0091240dd1ee75ad7420 100644 (file)
@@ -23,14 +23,16 @@ export class MarkdownService {
   }
 
   textMarkdownToHTML (markdown: string) {
-    const html = this.textMarkdownIt.render(markdown)
+    if (!markdown) return ''
 
+    const html = this.textMarkdownIt.render(markdown)
     return this.avoidTruncatedLinks(html)
   }
 
   enhancedMarkdownToHTML (markdown: string) {
-    const html = this.enhancedMarkdownIt.render(markdown)
+    if (!markdown) return ''
 
+    const html = this.enhancedMarkdownIt.render(markdown)
     return this.avoidTruncatedLinks(html)
   }
 
@@ -68,7 +70,7 @@ export class MarkdownService {
     }
   }
 
-  private avoidTruncatedLinks (html) {
-    return html.replace(/<a[^>]+>([^<]+)<\/a>\s*...(<\/p>)?$/mi, '$1...')
+  private avoidTruncatedLinks (html: string) {
+    return html.replace(/<a[^>]+>([^<]+)<\/a>\s*...((<\/p>)|(<\/li>)|(<\/strong>))?$/mi, '$1...')
   }
 }