3
votes

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

3 Answers

4
votes

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.

1
votes

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.

0
votes

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