简体   繁体   English

如何在 PDF 中预览和打印 markdown 文件,并在 VS Code 中使用特定于文件的 CSS 样式表?

[英]How to preview and print in PDF a markdown file with a file-specific CSS stylesheet in VS Code?

Here is my use case:这是我的用例:

I want to create a markdown document (my CV for instance) and create a style for it using a CSS file.我想创建一个 markdown 文档(例如我的简历)并使用 CSS 文件为其创建样式。 Then I want to print the PDF of my file.然后我想打印我的文件的 PDF 。

I have installed the Markdown PDF extension in VS Code and it does its job.我已经在 VS Code 中安装了Markdown PDF扩展,它完成了它的工作。

To have the extension and the preview to properly render the styling, I changed the settings in vscode setting.json for both extensions to use my CSS file and it works.为了让扩展和预览正确呈现样式,我更改了 vscode setting.json中的设置,以使用我的 CSS 文件,它可以工作。

For the preview:对于预览:

{
  "markdown.styles": ["my-styles.css"]
}

For the PDF export:对于 PDF 导出:

{
  "markdown-pdf.styles": ["~/Documents/Styles/my-styles.css"]
}

However, this stylesheet is applied to all my markdown files and what I would like is to embed the CSS file for this specific file.但是,此样式表适用于我的所有markdown 文件,我想要为这个特定文件嵌入 CSS 文件。 I want to have a CV style for my CVs, a report style for reports, etc.我想为我的 CV 设置一个 CV 样式,为报告设置一个报告样式等。

Is this feasible?这可行吗?

Using workspace specific settings solves my issue.使用工作区特定设置解决了我的问题。

It does not allow to use one CSS per markdown file, but it's good enough: I can put all my CVs in one folder with the CV CSS in the workspace settings and my reports in another workspace with another CSS stylesheet It does not allow to use one CSS per markdown file, but it's good enough: I can put all my CVs in one folder with the CV CSS in the workspace settings and my reports in another workspace with another CSS stylesheet

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM