I'm trying to render with pandoc a Markdown file containing math formulae into HTML with a template.
With
pandoc stuff.md -f markdown -t latex -s -o stuff.tex
pandoc --template=template.html --mathjax stuff.tex -f latex -t html -s -o stuff.html
no error is returned but the Latex and the CSS are not interpreted (although it works fine without template).
I've also tried what's proposed here and there but the result is unchanged.
Ultimately I could enrich my template with what is output without template, but this is ugly.
stuff.md:
---
title: 'Bla'
author: me
abstract: |
blablabla.
...
# Blablabla
blablabla
# Blablabla 2
$\mathbf{Definition}$\
Antisymmetry : $\forall x, y \in A, (xRy \land yRx) \implies x=y$,
# Conclusion
blablabla
template.html:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="template.css">
<title>Bla website</title>
</head>
<body class="body">
<div class="header-container">
<div class="header">
bla header
</div>
</div>
<div class="heart-container">
<div class="heart">
$body$
</div>
</div>
</body>
</html>
template.css:
.body {
background-color: #000000;
color: #B2F613;
font-family: Georgia, "Times New Roman", Times, serif;
margin: 0;
display: grid;
grid-template-columns: auto;
grid-template-rows: auto auto;
}
.header-container {
grid-row: 1;
grid-column: 1;
}
.header {
display: grid;
grid-template-columns: min-content auto;
grid-template-rows: auto;
align-items: end;
}
.heart {
display: grid;
grid-template-columns: auto;
grid-template-rows: auto;
margin: 1em;
align-items: center;
}
.heart-container {
grid-row: 2;
grid-column: 1;
}
The only thing I want is md -> html, but there are Latex formulae.
Then no need to use -t latex
. Just use:
pandoc -f md --mathjax --template=template.html stuff.md -o output.html`
But note that your template.html needs to load mathjax. To get a good starting point, use pandoc -D html > template.html
(which creates the template.html file in your current directory). Note the following part in the HTML <head>
, which will be replaced by the mathjax loading script:
$if(math)$
$math$
$endif$