Skip to content

MathJax not rendering, configuration file is not installed with the package. #192

@joaocandre

Description

@joaocandre

I'm having some issues getting MathJax to properly render math expression (even in the basic 'markdown' flavor) when building or previewing a markdown file with some inline and outline (through the use of align* tex environment) equations.

The documentation suggests using

"js": {
    "markdown": [
        "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js",
        "res://MarkdownPreview/js/math_config.js"
    ]
}

to load MathJax support, simply include the MathJax library along with the math config file provided by this extension, but I've found that has no effect whatsoever on the generated htm, and, notably, the configuration file is not installed with the package (?).

Instead, I was able to properly render math content by replacing the MathJax library with the v3 library (I understand this may not be fully supported by this package at the moment though, per #106):

"js": {
    "markdown": [
        "res://MarkdownPreview/js/math_config.js",
        "https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js",
        // "https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js",
    ]
}

I had to use the SVG renderer in order to avoid weird font issues when falling back to local fonts, but that is likely just specific to my setup;
nevertheless, this still did not render inline equations i.e. $ ... $, even when including the arithmatex extensions as suggested in the documentation (given the math_config.js is not available locally).
This can, however, be fixed by manually creating math_config.js with a minimal configuration:

window.MathJax = {
  tex: {
    inlineMath: [['$', '$'], ['\\(', '\\)']],
    displayMath: [['$$', '$$'], ['\\[', '\\]']],
  },
};

and including it before the rendering library in the

I'm sure there remaining configuration options would be useful as well, but in my case this was enough for a functional math rendering pipeline. As such, I'd suggest updating the documentation and adding an up-to-date, minimal working example such that math content is rendered out-of-the-box.

Metadata

Metadata

Assignees

No one assigned

    Labels

    S: triageIssue needs triage.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions