Sunday, 2 February 2020

Markup to Pdf/HTML

Markup to Pdf/HTML

Markup to Pdf/HTML

2019-07-27T20:39:13+01:00



Introduction

This documents shows the various ways to generate PDF and self contained HTML files.

Using VSCode extension.

Install VSCode and install extension Markdown PDF. Write a new markup page in VSCode. When done, right click on the editor and you will see the options to export to PDF and HTML.

  • pros
    1. Easy installation and generation of PDF
    2. Line wraps in code blocks.
  • cons
    1. Not very eye pleasing.
    2. Headings like h1, h2 are not consistent in rendered pdf.

Using pandoc/latex/Tex

Install pandoc, macTex and TeX Live. Create a workspace are and clone following two git repos in that workspace area.

mkdir $HOME/panDocs
cd $HOME/panDocs
git clone https://github.com/Wandmalfarbe/pandoc-latex-template.git
git clone https://github.com/tajmone/pandoc-goodies.git
  • pandoc-goodies is to generate html files.
  • pandox-latex-template is to generate pdf files.

Create an markup file in $HOME/panDocs say input.md.

Run following command to generate PDF

PDF generation

pandoc input.md -f markdown --template pandoc-latex-template/eisvogel.tex --listings -o output.pdf --highlight-style pygments  -V lang=en-GB -V listings-disable-line-numbers=true --toc --toc-depth 6

Above command will generate an pdf file of name output.pdf

Run following command to generate HTML:

Self contained HTML

pandoc input.md -f markdown --template pandoc-goodies/templates/html5/github/GitHub.html5 --self-contained --toc --toc-depth=6 -o output.html

Above command will generate a self contained HTML file of name output.html

No comments:

Post a Comment