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

Exclude default CSS if the styles configuration is set #49

Closed
vimtaai opened this issue Jan 17, 2018 · 1 comment
Closed

Exclude default CSS if the styles configuration is set #49

vimtaai opened this issue Jan 17, 2018 · 1 comment

Comments

@vimtaai
Copy link
Contributor

vimtaai commented Jan 17, 2018

Hi!
It would be nice to disable the default CSS if I'm using my own custom CSS with the markdown-pdf.styles option as the default one can interfere with custom styling.

All you have to do is to make the inclusion of the default CSS dependent of the number of defined custom styles. (Basically move lines 430 and 431 to the else branch of the if on line 435 in extension.js)

filename = path.join(__dirname, 'styles', 'markdown.css');

Proposed code snippet (extension.js)

  // 1. read the style of the markdown.styles setting.
  styles = vscode.workspace.getConfiguration('markdown')['styles'];
  if (styles && Array.isArray(styles) && styles.length > 0) {
    for (i = 0; i < styles.length; i++) {
      var href = filename = styles[i];
      var protocol = url.parse(href).protocol;
      if (protocol === 'http:' || protocol === 'https:') {
        style += '<link rel=\"stylesheet\" href=\"" + href + "\" type=\"text/css\">';
      } else if (protocol === 'file:') {
        style += makeCss(filename);
      }
    }
  } else {
    // 2. read the style of the vscode.
    filename = path.join(__dirname, 'styles', 'markdown.css');
    style += makeCss(filename);
  }

Another option would be to include a markdown-pdf.useDefaultStyle setting.

@vimtaai vimtaai changed the title Exclude default CSS the styles configuration is set Exclude default CSS if the styles configuration is set Jan 17, 2018
@vimtaai
Copy link
Contributor Author

vimtaai commented Jan 19, 2018

I actually see that I only referenced half of the code that needs to be changed so I created a new pull request #50 to solve this issue.

yzane added a commit that referenced this issue Mar 19, 2018
Add: markdown-pdf:includeDefaultStyles option #49
@yzane yzane closed this as completed Mar 19, 2018
tat3 pushed a commit to tat3/vscode-markdown-pdf-2 that referenced this issue Sep 4, 2022
Add: markdown-pdf:includeDefaultStyles option yzane#49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants