Skip to content
This repository has been archived by the owner on Feb 4, 2020. It is now read-only.

Replace relative file:// urls with absolute path. #1

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/previewContentProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ export default class PreviewContentProvider implements vscode.TextDocumentConten
let html = mjml2html(vscode.window.activeTextEditor.document.getText(), { level: 'skip', disableMinify: true });

if (html.html) {

const documentAbsoluteDir = path.dirname(vscode.window.activeTextEditor.document.uri.fsPath)
//replace relative file links with absolute, to correctly render images!
html.html = html.html.replace(/file:\/\/(?!\/)/g,'file://'+documentAbsoluteDir+'/')

return html.html;
}
}
Expand Down