Reputation:
Is there a way of converting a markdown file with html code to a pdf? I have the following in Atom preview:
To get the red color I used the following:
# <span style="color:red">The Apolytikion in Tone 5 </span>
But when I convert it into a pdf file via Pandoc I get this,
Is there a way to keep the red color?
Upvotes: 5
Views: 3739
Reputation: 22544
Pandoc allows to select the PDF engine used for the conversion. The default is to go via LaTeX and pdflatex, HTML will be lost. However, there are other engines that use HTML: wkhtmltopdf, weasyprint, and prince (prince is not free). E.g.,
pandoc --pdf-engine=wkhtmltopdf …
The respective program must be installed separately and in your PATH. You can download wkhtmltopdf from wkhtmltopdf.org; for WeasyPrint see https://weasyprint.org.
Upvotes: 7
Reputation: 443
The way is really go via LaTeX and not html. To use colors you need to introduce some YAML code in the beginning, to add latex packages.
Try changing your code for this :
---
header-includes:
- \usepackage{xcolor}
...
# \textcolor{red}{The Apolytikion in Tone 5}
Some text
And then just run pandoc inputfile.md -o outputfile.pdf
Upvotes: 0
Reputation: 27285
There are different possibilities. First you can use an online service to convert it.
https://www.markdowntopdf.com/
But when you use Atom there is a plugin for this.
https://atom.io/packages/markdown-pdf
With that plugin you have the functionality to convert your markdown to a PDF-file.
Upvotes: 1