diff options
author | Chocobozzz <me@florianbigard.com> | 2019-09-05 15:39:52 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-09-05 15:40:09 +0200 |
commit | 1eb23e12f757dc4e9a6161b1b933f35a761755c3 (patch) | |
tree | 1166c2d01d9aa2385c0049a4ae4556249ed1aeb5 /client/src/app/shared | |
parent | 5819e694ba238b5e4ee97347c6cf5ee7a82725b5 (diff) | |
download | PeerTube-1eb23e12f757dc4e9a6161b1b933f35a761755c3.tar.gz PeerTube-1eb23e12f757dc4e9a6161b1b933f35a761755c3.tar.zst PeerTube-1eb23e12f757dc4e9a6161b1b933f35a761755c3.zip |
Add contributors in about peertube page
Diffstat (limited to 'client/src/app/shared')
-rw-r--r-- | client/src/app/shared/renderer/markdown.service.ts | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/client/src/app/shared/renderer/markdown.service.ts b/client/src/app/shared/renderer/markdown.service.ts index 9a9066351..0e24f3085 100644 --- a/client/src/app/shared/renderer/markdown.service.ts +++ b/client/src/app/shared/renderer/markdown.service.ts | |||
@@ -13,9 +13,11 @@ export class MarkdownService { | |||
13 | 'list' | 13 | 'list' |
14 | ] | 14 | ] |
15 | static ENHANCED_RULES = MarkdownService.TEXT_RULES.concat([ 'image' ]) | 15 | static ENHANCED_RULES = MarkdownService.TEXT_RULES.concat([ 'image' ]) |
16 | static COMPLETE_RULES = MarkdownService.ENHANCED_RULES.concat([ 'block', 'inline', 'heading', 'html_inline', 'html_block', 'paragraph' ]) | ||
16 | 17 | ||
17 | private textMarkdownIt: MarkdownIt | 18 | private textMarkdownIt: MarkdownIt |
18 | private enhancedMarkdownIt: MarkdownIt | 19 | private enhancedMarkdownIt: MarkdownIt |
20 | private completeMarkdownIt: MarkdownIt | ||
19 | 21 | ||
20 | async textMarkdownToHTML (markdown: string) { | 22 | async textMarkdownToHTML (markdown: string) { |
21 | if (!markdown) return '' | 23 | if (!markdown) return '' |
@@ -39,11 +41,22 @@ export class MarkdownService { | |||
39 | return this.avoidTruncatedTags(html) | 41 | return this.avoidTruncatedTags(html) |
40 | } | 42 | } |
41 | 43 | ||
42 | private async createMarkdownIt (rules: string[]) { | 44 | async completeMarkdownToHTML (markdown: string) { |
43 | // FIXME: import('..') returns a struct module, containing a "default" field corresponding to our sanitizeHtml function | 45 | if (!markdown) return '' |
46 | |||
47 | if (!this.completeMarkdownIt) { | ||
48 | this.completeMarkdownIt = await this.createMarkdownIt(MarkdownService.COMPLETE_RULES, true) | ||
49 | } | ||
50 | |||
51 | const html = this.completeMarkdownIt.render(markdown) | ||
52 | return this.avoidTruncatedTags(html) | ||
53 | } | ||
54 | |||
55 | private async createMarkdownIt (rules: string[], html = false) { | ||
56 | // FIXME: import('...') returns a struct module, containing a "default" field corresponding to our sanitizeHtml function | ||
44 | const MarkdownItClass: typeof import ('markdown-it') = (await import('markdown-it') as any).default | 57 | const MarkdownItClass: typeof import ('markdown-it') = (await import('markdown-it') as any).default |
45 | 58 | ||
46 | const markdownIt = new MarkdownItClass('zero', { linkify: true, breaks: true }) | 59 | const markdownIt = new MarkdownItClass('zero', { linkify: true, breaks: true, html }) |
47 | 60 | ||
48 | for (const rule of rules) { | 61 | for (const rule of rules) { |
49 | markdownIt.enable(rule) | 62 | markdownIt.enable(rule) |