Skip to content

MathJax.typeset(): How does it work? #240

@msrumon

Description

@msrumon

Hi,
In version 2, I used to use MathJax.Hub.Typeset(<element>) to typeset dynamically loaded contents. In version 3, I am trying to use Mathjax.typeset(<element>), but I get the following error:

Uncaught TypeError: Object is not iterable.

I am following this doc. And here is my configuration:

/* === other codes === */
case "/academic":
    const loadMathJax = document.createElement("script"), configMathJax = document.createElement("script");
    document.head.appendChild(configMathJax);
    document.head.appendChild(loadMathJax);
    loadMathJax.src = "scripts/mathjax.js"; // this file is carbon-copy of 'tex-mml-chtml.js'
    configMathJax.innerText = `window.MathJax = { options: { ignoreHtmlClass: "tex2jax_ignore", processHtmlClass: "tex2jax_process" }, tex: { autoload: { color: [], colorV2: ["color"] }, packages: { "[+]": ["noerrors"] } }, loader: { load: ["input/asciimath", "[tex]/noerrors", "[tex]/mhchem"] } }`;
    /* === other codes === */
    li.onclick = () => {
        const res = document.createElement("div");
        /* === other codes === */
        inner.appendChild(res);
        res.innerHTML = each.content;
        window.MathJax.typeset(res); // this line is kicking the error
    };
/* === other codes === */

Maybe I am missing something, can I get a little more guideline on how this function works?
Thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions