aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/core/renderer/markdown.service.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/core/renderer/markdown.service.ts')
-rw-r--r--client/src/app/core/renderer/markdown.service.ts14
1 files changed, 7 insertions, 7 deletions
diff --git a/client/src/app/core/renderer/markdown.service.ts b/client/src/app/core/renderer/markdown.service.ts
index 36258ca98..a81d99534 100644
--- a/client/src/app/core/renderer/markdown.service.ts
+++ b/client/src/app/core/renderer/markdown.service.ts
@@ -103,20 +103,20 @@ export class MarkdownService {
103 const { name, markdown, withEmoji, additionalAllowedTags } = options 103 const { name, markdown, withEmoji, additionalAllowedTags } = options
104 if (!markdown) return '' 104 if (!markdown) return ''
105 105
106 const config = this.parsersConfig[ name ] 106 const config = this.parsersConfig[name]
107 if (!this.markdownParsers[ name ]) { 107 if (!this.markdownParsers[name]) {
108 this.markdownParsers[ name ] = await this.createMarkdownIt(config) 108 this.markdownParsers[name] = await this.createMarkdownIt(config)
109 109
110 if (withEmoji) { 110 if (withEmoji) {
111 if (!this.emojiModule) { 111 if (!this.emojiModule) {
112 this.emojiModule = (await import('markdown-it-emoji/light')).default 112 this.emojiModule = (await import('markdown-it-emoji/light')).default
113 } 113 }
114 114
115 this.markdownParsers[ name ].use(this.emojiModule) 115 this.markdownParsers[name].use(this.emojiModule)
116 } 116 }
117 } 117 }
118 118
119 let html = this.markdownParsers[ name ].render(markdown) 119 let html = this.markdownParsers[name].render(markdown)
120 html = this.avoidTruncatedTags(html) 120 html = this.avoidTruncatedTags(html)
121 121
122 if (config.escape) return this.htmlRenderer.toSafeHtml(html, additionalAllowedTags) 122 if (config.escape) return this.htmlRenderer.toSafeHtml(html, additionalAllowedTags)
@@ -156,7 +156,7 @@ export class MarkdownService {
156 if (relIndex < 0) token.attrPush([ 'rel', 'noopener noreferrer' ]) 156 if (relIndex < 0) token.attrPush([ 'rel', 'noopener noreferrer' ])
157 else token.attrs[relIndex][1] = 'noopener noreferrer' 157 else token.attrs[relIndex][1] = 'noopener noreferrer'
158 158
159 // pass token to default renderer. 159 // pass token to default renderer.*
160 return defaultRender(tokens, index, options, env, self) 160 return defaultRender(tokens, index, options, env, self)
161 } 161 }
162 } 162 }
@@ -164,7 +164,7 @@ export class MarkdownService {
164 private avoidTruncatedTags (html: string) { 164 private avoidTruncatedTags (html: string) {
165 return html.replace(/\*\*?([^*]+)$/, '$1') 165 return html.replace(/\*\*?([^*]+)$/, '$1')
166 .replace(/<a[^>]+>([^<]+)<\/a>\s*...((<\/p>)|(<\/li>)|(<\/strong>))?$/mi, '$1...') 166 .replace(/<a[^>]+>([^<]+)<\/a>\s*...((<\/p>)|(<\/li>)|(<\/strong>))?$/mi, '$1...')
167 .replace(/\[[^\]]+\]\(([^\)]+)$/m, '$1') 167 .replace(/\[[^\]]+\]\(([^)]+)$/m, '$1')
168 .replace(/\s?\[[^\]]+\]?[.]{3}<\/p>$/m, '...</p>') 168 .replace(/\s?\[[^\]]+\]?[.]{3}<\/p>$/m, '...</p>')
169 } 169 }
170} 170}