import * as MarkdownIt from 'markdown-it'
-import { buildVideoLink, decorateVideoLink } from 'src/assets/player/utils'
import { Injectable } from '@angular/core'
+import { buildVideoLink, decorateVideoLink } from '@shared/core-utils'
import {
COMPLETE_RULES,
ENHANCED_RULES,
url: buildVideoLink({ shortUUID: videoShortUUID }),
startTime: t
})
+
+ // Sync class name with timestamp-route-transformer directive
return `<a class="video-timestamp" href="${url}">${str}</a>`
})
}
const { name, markdown, withEmoji, additionalAllowedTags } = options
if (!markdown) return ''
- const config = this.parsersConfig[ name ]
- if (!this.markdownParsers[ name ]) {
- this.markdownParsers[ name ] = await this.createMarkdownIt(config)
+ const config = this.parsersConfig[name]
+ if (!this.markdownParsers[name]) {
+ this.markdownParsers[name] = await this.createMarkdownIt(config)
if (withEmoji) {
if (!this.emojiModule) {
this.emojiModule = (await import('markdown-it-emoji/light')).default
}
- this.markdownParsers[ name ].use(this.emojiModule)
+ this.markdownParsers[name].use(this.emojiModule)
}
}
- let html = this.markdownParsers[ name ].render(markdown)
+ let html = this.markdownParsers[name].render(markdown)
html = this.avoidTruncatedTags(html)
if (config.escape) return this.htmlRenderer.toSafeHtml(html, additionalAllowedTags)
if (relIndex < 0) token.attrPush([ 'rel', 'noopener noreferrer' ])
else token.attrs[relIndex][1] = 'noopener noreferrer'
- // pass token to default renderer.
+ // pass token to default renderer.*
return defaultRender(tokens, index, options, env, self)
}
}
private avoidTruncatedTags (html: string) {
return html.replace(/\*\*?([^*]+)$/, '$1')
.replace(/<a[^>]+>([^<]+)<\/a>\s*...((<\/p>)|(<\/li>)|(<\/strong>))?$/mi, '$1...')
- .replace(/\[[^\]]+\]\(([^\)]+)$/m, '$1')
+ .replace(/\[[^\]]+\]\(([^)]+)$/m, '$1')
.replace(/\s?\[[^\]]+\]?[.]{3}<\/p>$/m, '...</p>')
}
}