shd101wyy / vscode-markdown-preview-enhanced

One of the "BEST" markdown preview extensions for Visual Studio Code
https://shd101wyy.github.io/markdown-preview-enhanced
Other
1.48k stars 173 forks source link

Puppeteer change print 'theme' #291

Open mshiner opened 5 years ago

mshiner commented 5 years ago

First off - well done for a great add in.

Before discovering MPE I used VScode to write up my markdown file and then opened it in Chromium with the markdown viewer extension. This provided a nice print/save using the Github theme but without the flexibility of doing everything 'within' VScode... plus all of the other goodies you provide (page headers and footers TOC etc etc).

But.... the default puppeteer pdf that is generated has a different 'theme' from the one I used before, and I'm struggling to understand how to change the style of PDF output produced.

Any help would greatly appreciated.... Thanks

shd101wyy commented 5 years ago

There is a settings called “printBackground” or something in extension settings. Turn it on then the theme you chose will be used in print.

mshiner commented 5 years ago

Wow.... quick response!

OK tried that, but didn't really do what I wanted. So I opened the MD file again in chromium and looked at the source. Its using a stylesheet as follows....

chrome-extension://ckkdlimhmcjmikdlpkmbgfkaikojcbjk/themes/github.css

This gives a particular style that I like - I think its from here, maybe https://github.com/sindresorhus/github-markdown-css

Can I use this custom css to generate the pdf? Sorry if this a basic question.

Thanks

tmori3y2 commented 5 years ago
  1. download css
  2. change extension into less

Try it

---
class: "markdown-body"
---
@import "github-markdown-css.less"

# Title

your contents...
bw-itis-archival commented 4 years ago

Would it be possible to add some VS Code user settings to reference CSS or LESS stylesheets in the workspace (either absolute or relative to the document)? This is the approach used by the build-in markdown preview, and the Markdown-PDF extension. I would really prefer this to an import (although the imports are very useful), since it means that I can keep a "standard" markdown document that will parse in other engines. Currently if I want to use say pandoc, I just get the import in text. I've noticed you can change the styles using settings in ~/.mume but this is not very useful to me since I need to set up a workspace that will produce a consistent preview and export on different PCs after checking out a project - I can't rely on things in the user directory. This is really the only thing I can find missing from this plugin at the moment.