LaTeX.js icon indicating copy to clipboard operation
LaTeX.js copied to clipboard

latex-parser.pegjs.js:825 "Two \\documentclass commands. The document may only declare one class"

Open artistl opened this issue 6 months ago • 1 comments

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>

artistl avatar Aug 12 '24 17:08 artistl