LaTeX.js
LaTeX.js copied to clipboard
latex-parser.pegjs.js:825 "Two \\documentclass commands. The document may only declare one class"
Is there any obvious reason to be getting this error in the js console? I think I'm doing everything right...? My first time calling doPandoc(), everything works. But the second+ times I get this error. What is received back from the HTTP response is not a standalone latex doc... it has nothing like \documentclass.
<head>
<script src="https://cdn.jsdelivr.net/npm/latex.js/dist/latex.js"></script>
</head>
...
<script>
var isFirst = true
let generator = new latexjs.HtmlGenerator({hyphenate: false})
function doPandoc() {
var contents = document.getElementById("in").value;
$.post(
"/kip/editor/pandoc",
{markdown: contents},
function(data) {
generator = latexjs.parse(data, {generator: generator})
if (isFirst) {
document.head.appendChild(generator.stylesAndScripts("https://cdn.jsdelivr.net/npm/[email protected]/dist/"))
}
isFirst = false
document.body.appendChild(generator.domFragment())
}
)
}
</script>