Skip to content

Commit

Permalink
feat: add bind image support
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Mar 11, 2020
1 parent 1dc1050 commit 63badfd
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,21 @@ export class MarkdownRenderComponent implements OnInit {
constructor(private markdownService: MarkdownService) { }

ngOnInit(): void {
const markedOptions: any = this.markdownService.options;
this.markdownService.renderer.image = (href: string, title: string, text: string): string => {
if (href === null) {
return text;
}
let out = '<img src="' + href + '" alt="' + text + '"';
if (title) {
out += ' title="' + title + '"';
}

out += markedOptions.xhtml ? '/>' : '>';
out += `<figcaption>${title}</figcaption>`;
return `<figure>${out}</figure>`;
};

// this.markdownService.renderer.table = (header: string, body: string) => {
// return '';
// };
Expand Down
2 changes: 1 addition & 1 deletion src/assets/docs/pattern.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
![Fluent Agency](assets/images/agile-fluency.png)
![Fluent Agency](assets/images/agile-fluency.png "Fluent Agency")
6 changes: 6 additions & 0 deletions src/styles/_markdown.scss
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,12 @@
margin: 1em auto;
}

figcaption {
text-align: center;
padding: 8px;
color: #ccc;
}

a {
color: #1abc9c;
text-decoration: none
Expand Down

0 comments on commit 63badfd

Please sign in to comment.