improve image source extraction for remote cases, https://github.com/kisstkondoros/gutter-preview/issues/57

This commit is contained in:
Johannes Rieken
2019-07-11 11:25:31 +02:00
parent ff703d81f4
commit e9d8aaafcb
3 changed files with 30 additions and 23 deletions

View File

@@ -237,8 +237,7 @@ export namespace MarkdownString {
const resUris: { [href: string]: UriComponents } = Object.create(null);
res.uris = resUris;
const renderer = new marked.Renderer();
renderer.image = renderer.link = (href: string): string => {
const collectUri = (href: string): string => {
try {
let uri = URI.parse(href, true);
uri = uri.with({ query: _uriMassage(uri.query, resUris) });
@@ -248,6 +247,10 @@ export namespace MarkdownString {
}
return '';
};
const renderer = new marked.Renderer();
renderer.link = collectUri;
renderer.image = href => collectUri(htmlContent.parseHrefAndDimensions(href).href);
marked(res.value, { renderer });
return res;