如何转换Markdown + CSS-> PDF? [英] How to convert Markdown + CSS -> PDF?

查看:118
本文介绍了如何转换Markdown + CSS-> PDF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将Markdown文件转换为PDF.我只在寻找两件事:

I'm trying to convert a Markdown file into a PDF. I'm looking for only two things:

  • 一种轻松更改pdf样式的方法(例如,使用CSS文件)
  • 用于代码块的语法突出显示

我可以使用哪些工具?我尝试过Pandoc,但是它使用Latex进行格式化,使用起来并不容易.

What tools can I use for that? I tried Pandoc, but it uses Latex for the formatting which is not easy to use.

推荐答案

Pandoc可以将Markdown转换为HTML,但是样式/布局是不同的主题.如果要生成PDF但使用CSS进行样式设置,则需要可以解释CSS的内容.也就是说,要么使用浏览器并打印为PDF,要么为 Prince 付费,或尝试

Pandoc can convert your Markdown to HTML, but the styling/layout is a different topic. If you want to produce a PDF but use CSS for styling, you need something that can interpret CSS. That is either use a browser and print to PDF, pay for Prince or try wkhtmltopdf. Btw, pandoc can also use wkhtmltopdf now:

pandoc -t html --css mystyles.css input.md -o output.pdf

但是我怀疑,如果您想免费获得精美排版的PDF,则必须学习LaTeX或 ConTeXt 是LaTeX的现代且更独立的替代品,两者都可以与pandoc一起使用.请参见使用pandoc创建PDF .

But I suspect if you want a beautifully-typeset PDF for free you'll have to learn LaTeX or ConTeXt which is a modern and more self-contained replacement for LaTeX, both can be used with pandoc. See creating a PDF with pandoc.

您还可以尝试 PanWriter :我构建的markdown编辑器,可以在其中插入CSS并导出PDF在分页预览中.

You can also give PanWriter a try: a markdown editor I built, where you can inject CSS and export the PDF from the paginated preview.

这篇关于如何转换Markdown + CSS-> PDF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆