Skip to content

mathml2chtml fails with a newline at the end. #2805

Closed
@NSoiffer

Description

@NSoiffer

Issue Summary

A newline at the end of some MathML in a call to mathml2chtml causes an error (actually, the call never returns)
This works

MathJax.mathml2chtml("<math><mi>XXX</mi></math>");

This fails:

MathJax.mathml2chtml("<math><mi>XXX</mi></math>\n");

Steps to Reproduce:

I tried to get a codepen example to run, and codepen complained about "MathJax" not being defined. Here's some HTML that shows the problem (the "AFTER..." is never shown):

<!DOCTYPE html>
<html>
<head>
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/mml-chtml.js"></script> 
<script>
function ConvertMathML() {
  MathJax.startup.defaultReady();
  document.getElementById("before").innerHTML = "BEFORE conversion";
  let foo = MathJax.mathml2chtml("<math><mi>XXX</mi></math>\n");
  document.getElementById("after").innerHTML = "AFTER conversion";
}
</script>
</head>
<body>
<button onclick="ConvertMathML()"> Click me to see bug </button>
<p id="before"></p>
<p id="after"></p>
</body>
</html>

Metadata

Metadata

Assignees

No one assigned

    Labels

    AcceptedIssue has been reproduced by MathJax teamCode ExampleContains an illustrative code example, solution, or work-aroundFeature RequestFixedv3v3.2

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions