MathJax icon indicating copy to clipboard operation
MathJax copied to clipboard

new SVG() crashing

Open pkra opened this issue 2 years ago • 1 comments

Just a random note in case you consider it relevant

While

import { SVG } from 'mathjax-full/js/output/svg.js';
const svg = new SVG({});

is ok, this

import { SVG } from 'mathjax-full/js/output/svg.js';
const svg = new SVG();

throws for me (4-beta4) with

[snip]node_modules/mathjax-full/mjs/output/common.js:17
        const [fontClass, font] = (options.fontData instanceof FontData ?
                                           ^

TypeError: Cannot read properties of null (reading 'fontData')
    at new CommonOutputJax ([snip]node_modules/mathjax-full/mjs/output/common.js:17:44)
    at new SVG ([snip]node_modules/mathjax-full/mjs/output/svg.js:15:9)
    at [snip]mjtest.js:2:13
    at ModuleJob.run (node:internal/modules/esm/module_job:192:25)
    at async DefaultModuleLoader.import (node:internal/modules/esm/loader:228:24)
    at async loadESM (node:internal/process/esm_loader:40:7)
    at async handleMainPromise (node:internal/modules/run_main:66:12)

Node.js v20.5.1

pkra avatar Nov 10 '23 21:11 pkra

Thanks for the pointer. It is due to an incorrect default value in the SVG class constructor (and in the underlying common output jax constructor). It is an easy fix, and I'll make a PR for it.

dpvc avatar Nov 11 '23 13:11 dpvc