I'm trying to convert a simple latex file (named book.tex), that has custom latex macros, into html.
\begin{document}
\chapter{Chapter heading}
\chapsummary {
\item Intro bullet 1
\item Intro bullet 2
}
Some paragraph of text.
\end{document}
Where \chapsummary is just an example of a macro (it might become more elaborate later) that outputs a bullet list.
If I define it at the beginning of this document, then all is well. When I run pandoc book.tex -o book.html
I get the following html:
...
<body>
<h1 id="chapter-heading">Chapter heading</h1>
<ul>
<li><p>Intro bullet 1</p></li>
<li><p>Intro bullet 2</p></li>
</ul>
<p>Some paragraph of text.</p>
</body>
...
Ideally, I would like to define it in a separate file (so that it can be easily included in the conversion process, without modifying the original content files). Unfortunately, everything else I tried resulted in the list not being displayed.
I tried creating a metadata.json file:
{
"header-includes": [
"\\newcommand{\\chapsummary}[1]{ \\begin{itemize} \\#1 \\end{itemize}}",
]
}
And then running pandoc --metadata-file=metadata.json -s book.tex -o book.html
. But nothing happens (the same thing happens if I pass in a yaml file). The bullet list is never transformed into HTML.
I've also tried putting the command in a separate latex file (e.g. commands.tex) and then running pandoc --include-in-header=commands.tex book.tex -o book.html
but that just prints the commands.tex content to the html as regular text, and doesn't do any macro replacement.
Put the macros into a second .tex
file, and to pass it as a normal input file to pandoc:
pandoc macros.tex book.tex -o book.html
This works because pandoc treats multiple input files as if they were a single file, with newlines between each file.