diff options
author | Chocobozzz <me@florianbigard.com> | 2018-01-31 16:42:40 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-01-31 16:42:40 +0100 |
commit | 66b16cafb380012d3eca14e524d86f2450e04069 (patch) | |
tree | 02a6d2327e2499dbe921c22a03b8a9d741773dd6 /client/src/app/videos/shared | |
parent | 81ebea48bfba2d81e62dd7a0f01a0cadf41d2607 (diff) | |
download | PeerTube-66b16cafb380012d3eca14e524d86f2450e04069.tar.gz PeerTube-66b16cafb380012d3eca14e524d86f2450e04069.tar.zst PeerTube-66b16cafb380012d3eca14e524d86f2450e04069.zip |
Add new name/terms/description config options
Diffstat (limited to 'client/src/app/videos/shared')
-rw-r--r-- | client/src/app/videos/shared/markdown.service.ts | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/client/src/app/videos/shared/markdown.service.ts b/client/src/app/videos/shared/markdown.service.ts index 82745f0c6..fd0330f9b 100644 --- a/client/src/app/videos/shared/markdown.service.ts +++ b/client/src/app/videos/shared/markdown.service.ts | |||
@@ -14,6 +14,17 @@ export class MarkdownService { | |||
14 | .enable('link') | 14 | .enable('link') |
15 | .enable('newline') | 15 | .enable('newline') |
16 | 16 | ||
17 | this.setTargetToLinks() | ||
18 | } | ||
19 | |||
20 | markdownToHTML (markdown: string) { | ||
21 | const html = this.markdownIt.render(markdown) | ||
22 | |||
23 | // Avoid linkify truncated links | ||
24 | return html.replace(/<a[^>]+>([^<]+)<\/a>\s*...(<\/p>)?$/mi, '$1...') | ||
25 | } | ||
26 | |||
27 | private setTargetToLinks () { | ||
17 | // Snippet from markdown-it documentation: https://github.com/markdown-it/markdown-it/blob/master/docs/architecture.md#renderer | 28 | // Snippet from markdown-it documentation: https://github.com/markdown-it/markdown-it/blob/master/docs/architecture.md#renderer |
18 | const defaultRender = this.markdownIt.renderer.rules.link_open || function (tokens, idx, options, env, self) { | 29 | const defaultRender = this.markdownIt.renderer.rules.link_open || function (tokens, idx, options, env, self) { |
19 | return self.renderToken(tokens, idx, options) | 30 | return self.renderToken(tokens, idx, options) |
@@ -33,11 +44,4 @@ export class MarkdownService { | |||
33 | return defaultRender(tokens, idx, options, env, self) | 44 | return defaultRender(tokens, idx, options, env, self) |
34 | } | 45 | } |
35 | } | 46 | } |
36 | |||
37 | markdownToHTML (markdown: string) { | ||
38 | const html = this.markdownIt.render(markdown) | ||
39 | |||
40 | // Avoid linkify truncated links | ||
41 | return html.replace(/<a[^>]+>([^<]+)<\/a>\s*...(<\/p>)?$/mi, '$1...') | ||
42 | } | ||
43 | } | 47 | } |