Pandoc - Quick Tips #1

04/07/2021, Wed
Categories: #shell
Tags: #pandoc

Render Full Html Site

By default, converting a LaTeX file into an HTML file only produces a partial HTML page. Pandoc conversion strictly contains the content wrapped in the basic HTML equivalent tags, which is spartan as the following example would only output a paragraph tag without a html, head, nor body tag available.

\documentclass{article}

\usepackage[margin=0.5in]{geometry}
\title{Tex}
\date{}

\begin{document}
\maketitle

some content

\end{document}

To fix this problem, the "full html" page requires the "-s" flag (standalone mode) to achieve the proper conversion.

pandoc -o 'my-output-file.html' 'my-input-file.tex' -s

Change the Default Template for HTML Display

For customization of the default html template which Pandocs uses to produces the HTML output, use the flag 'data-dir' to specify the directory for where the custom html template is located and the 'template' flag for pointing to the actual HTML template.

pandoc --data-dir='my-custom-directory/for/config/' --template='default.html5' -o 'my-output-file.html' 'my-input-file.tex' -s

The default sample 'default.html5' file can be found here.