From b29bf61dbd518e5cef0b2f564ddc8f8a0657d089 Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Mon, 16 Dec 2019 16:21:42 +0100 Subject: Provide native links for description timestamps, and re-clickability for these --- client/src/app/shared/renderer/markdown.service.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'client/src/app/shared/renderer') diff --git a/client/src/app/shared/renderer/markdown.service.ts b/client/src/app/shared/renderer/markdown.service.ts index f6b71b88a..0d3fde537 100644 --- a/client/src/app/shared/renderer/markdown.service.ts +++ b/client/src/app/shared/renderer/markdown.service.ts @@ -75,6 +75,14 @@ export class MarkdownService { return this.render('completeMarkdownIt', markdown) } + async processVideoTimestamps (html: string) { + return html.replace(/((\d{1,2}):)?(\d{1,2}):(\d{1,2})/g, function (str, _, h, m, s) { + const t = (3600 * +(h || 0)) + (60 * +(m || 0)) + (+(s || 0)) + const url = buildVideoLink({ startTime: t }) + return `${str}` + }) + } + private async render (name: keyof MarkdownParsers, markdown: string) { if (!markdown) return '' @@ -91,14 +99,6 @@ export class MarkdownService { return html } - async processVideoTimestamps (html: string) { - return html.replace(/((\d{1,2}):)?(\d{1,2}):(\d{1,2})/g, function (str, _, h, m, s) { - const t = (3600 * +(h || 0)) + (60 * +(m || 0)) + (+(s || 0)) - const url = buildVideoLink({ startTime: t }) - return `${str}` - }) - } - private async createMarkdownIt (config: MarkdownConfig) { // FIXME: import('...') returns a struct module, containing a "default" field corresponding to our sanitizeHtml function const MarkdownItClass: typeof import ('markdown-it') = (await import('markdown-it') as any).default @@ -139,7 +139,7 @@ export class MarkdownService { private avoidTruncatedTags (html: string) { return html.replace(/\*\*?([^*]+)$/, '$1') .replace(/]+>([^<]+)<\/a>\s*...((<\/p>)|(<\/li>)|(<\/strong>))?$/mi, '$1...') - .replace(/\[[^\]]+\]?\(?([^\)]+)$/, '$1') + .replace(/\[[^\]]+\]\(([^\)]+)$/m, '$1') .replace(/\s?\[[^\]]+\]?[.]{3}<\/p>$/m, '...

') } } -- cgit v1.2.3