mathjax / mathjax/MathJax

brackets from macros get matched in comments

Open
#3,577 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Accepted Ready for Review
Dominant language
JavaScript
Stars
10.9k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

Issue Summary

When there is a macro that takes an argument, the first closing bracket gets used, even when it is inside a latex comment.
Since this is not an issue when there is no macro but just brackets, I assume its a bug? from quick search, couldn't find anything indicating its not.

Steps to Reproduce:

render the math

$$
\text{hello
%}
world}
$$

Should produce the same as

$$
\text{hello
world}
$$

where as

$$
{
hello %}
}
$$

doesn't give an error

Technical details:
  • MathJax Version: 4
  • Client OS: windows 10
  • Browser: librewolf 151.0.4-1
Supporting information:

using basic html template

<!doctype html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <title>Page Title</title>
        <script
            defer
            src="https://cdn.jsdelivr.net/npm/mathjax@4/tex-mml-chtml.js"
        ></script>
    </head>
    <body>
        <div>$$\text{
			a%b}
		c}$$
	</div>
    </body>
</html>

produces

Image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the examples with the MathJax 4 tex-mml-chtml.js entry point, focusing on how the \text macro matches arguments across LaTeX comments. Done means a closing bracket inside a comment is ignored for macro matching while ordinary brace handling remains unchanged, with the reported cases verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, latex
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.