Markdown To HTML
Fake Latex For Assignments
Courses demand I use LaTeX, but I want to use markdown, so I will make fake LaTeX.
Workflow:
write markdown in normal editor -> convert to HTML via pandoc -> Style HTML using a lookalike stylesheet -> covert html to pdf (by printing in browser) -> submit
Note: Pandoc can also do direct MD -> LaTeX coversions
I will use Latex.vercel.app style sheet.
<link rel="stylesheet" href="https://unpkg.com/latex.css/style.min.css" />
Final pandoc command: pandoc --mathml -o=output.html --template=template.html input.md
See template.html
below
Relevant Docs:
- Pandoc templates
- standalone
-s
,--standalone
- see defualt template
pandoc -D html
--template=file.html
- standalone
- break-after: page
- MDN docs for
<hr>
tag - Markdown
---
line is converted into<hr>
hr {break-after: page}
allows to split pages of the pdf
- MDN docs for
- MathJax converter
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
- Pandoc Math reendering in HTML (tldr use
--mathml
)
template.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Fake Latex Assignment</title>
<meta name="viewport" content="width=device-width,initial-scale=1" />
<meta name="description" content="Description Goes Here" />
<link rel="stylesheet" href="https://unpkg.com/latex.css/style.min.css" />
<style>
hr {
break-after: page;
visibility: hidden;
}
</style>
</head>
<body>
$body$
</body>
</html>