Skip to content

Commit

Permalink
motplotlib fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dmca-glasgow committed Oct 2, 2023
1 parent 7ca5d4e commit 7ccdc69
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions compiler/src/mdast/embed-asset-url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,19 @@ export function embedAssetUrl(ctx: Context) {
}

function getPath(url: string, dirname: string, ctx: Context) {
return path.isAbsolute(url) ||
url.startsWith('http') ||
ctx.options.noEmbedAssetUrl
? url
: path.join(dirname, url);
if (ctx.options.noEmbedAssetUrl) {
return url;
}
if (path.isAbsolute(url) || url.startsWith('http')) {
return url;
}
// pythons matplotlib appears to assign plot images a path
// relative to the project root, whereas all other libraries use
// an absolute path.
if (url.startsWith('cache')) {
return path.join(ctx.cacheDir, url.replace('cache', ''));
}
return path.join(dirname, url);
}

function getProps(value: string) {
Expand Down

0 comments on commit 7ccdc69

Please sign in to comment.