Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relative CSS does not work #126

junkoya opened this issue Apr 11, 2019 · 4 comments


Copy link

commented Apr 11, 2019

I wrote .md file and .css file in same directory.

# chapter
## subject

Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
  • markdownpdf.css
h1 {
    background-color: black;
    color: white;
    font-size: 48pt;
    font-weight: bold;

h2 {
    font-size: 32pt;
    text-decoration-line: underline;

And I wrote settings.json as below:

"markdown-pdf.stylesRelativePathFile": true,
"markdown-pdf.styles": ["markdownpdf.css"]

But output pdf is like below:


Maybe, this tag on html is failed.

  • test.html
<link rel="stylesheet" href="file:///markdownpdf.css" type="text/css">

When I modify it as below, it works.

<link rel="stylesheet" href="./markdownpdf.css" type="text/css">



This comment has been minimized.

Copy link

commented Apr 12, 2019

I also have this issue. It worked in the past, but Visual Studio updated this week, so maybe there is a breaking extension API change.


This comment has been minimized.

Copy link

commented May 5, 2019

Just wanted to affirm this issue and give some version hints.

VS Code Environment:
Version: 1.33.1 (user setup)
Commit: 51b0b28134d51361cf996d2f0a1c698247aeabd8
Date: 2019-04-11T08:27:14.102Z
Electron: 3.1.6
Chrome: 66.0.3359.181
Node.js: 10.2.0
V8: 6.6.346.32
OS: Windows_NT x64 10.0.17763

Name: Markdown PDF
Id: yzane.markdown-pdf
Description: Convert Markdown to PDF
Version: 1.2.0
Publisher: yzane


This comment has been minimized.

Copy link

commented May 5, 2019

With VS Code Version 1.32 relative CSS paths are still working. So it seems a breaking change was introduced with 1.33.


This comment has been minimized.

Copy link

commented Aug 13, 2019

I also have this issue.

I think the cause is following code.

const hrefUri = vscode.Uri.parse(href);

From version 1.33, vscode.Uri.parse(href) returns file URI scheme such as file:///relative_path.css when href is a relative path such as relative_path.css.
(Version 1.32 returns the same string as href)

Change the following line

if (path.isAbsolute(href) || hrefUri.scheme === 'file') {


if (path.isAbsolute(href)) {

, then it worked.

Here is my version info.
Version: 1.37.0 (user setup)
Commit: 036a6b1d3ac84e5ca96a17a44e63a87971f8fcc8
Date: 2019-08-08T02:33:50.993Z
Electron: 4.2.7
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Windows_NT x64 10.0.17763

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
4 participants
You can’t perform that action at this time.