Is it possible to convert a markdown file with html into pdf?

Viewed 1544

Is there a way of converting a markdown file with html code to a pdf? I have the following in Atom preview:

enter image description here

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,

enter image description here

Is there a way to keep the red color?

3 Answers

Pandoc allows to select the PDF engine used for conversion. The default is to go via LaTeX and pdflatex, HTML will be lost. However, there are other engines which 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.

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

Related