Skip to content

Change to mathjax 4 for format preview - #1598

Closed
70ray wants to merge 1 commit into
DistributedProofreaders:masterfrom
70ray:mj4
Closed

Change to mathjax 4 for format preview#1598
70ray wants to merge 1 commit into
DistributedProofreaders:masterfrom
70ray:mj4

Conversation

@70ray

@70ray 70ray commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

@70ray
70ray requested review from chrismiceli, cpeel and mrducky4 July 15, 2026 11:54
@cpeel
cpeel requested a review from windymilla July 15, 2026 22:18
@cpeel

cpeel commented Jul 15, 2026

Copy link
Copy Markdown
Member

I've added a sandbox to the PR but haven't tested it myself.

A nice-to-have (not in this PR) would be to get this bundled as part of our deployment process so it's served locally instead of via the CDN.

prevWin.innerHTML = preview.txtout;
if (preview.ok && previewStyles.allowMathPreview) {
try {
MathJax.typeset([prevWin]);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this is still ok with MathJax 4? From Upgrading from v3 to v4:

If you are calling the MathJax API, then you may need to change to using the promise-based calls like MathJax.typesetPromise() rather than the synchronous ones like MathJax.typeset(). See the MathJax v4.0 and Promises section for details and suggestions for how to proceed.

Update: I tried the sandbox. For the first thing I tried, I got this error:

MathJax error: Error: MathJax retry -- an asynchronous action is required; try using one of the promise-based functions and await its resolution.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this is still ok with MathJax 4? From Upgrading from v3 to v4:

If you are calling the MathJax API, then you may need to change to using the promise-based calls like MathJax.typesetPromise() rather than the synchronous ones like MathJax.typeset(). See the MathJax v4.0 and Promises section for details and suggestions for how to proceed.

Update: I tried the sandbox. For the first thing I tried, I got this error:

MathJax error: Error: MathJax retry -- an asynchronous action is required; try using one of the promise-based functions and await its resolution.

@mrducky4 -- can you share what you used to test with? I'm not even a novice LaTeX/MathJax user, so I have to look in existing projects for things to test with.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used the same math markup that is in PR #1527, copied here:

Thus we are led to three general definitions for descriptive double
functions, namely (if \(x\unicode{x2640} y\) be any such function)
\[
\begin{aligned}
x\unicode{x2640} \text{ is the relation of }x\unicode{x2640} y\text{ to }&y\text{ for any }y,\\
\unicode{x2640} y\quad "\quad "\quad "\quad "\quad " &x\quad "\quad x,\\
\alpha \unicode{x2640}_{,,} y\text{ is the class of values of }&x\unicode{x2640} y\text{ when }x\text{ is an }\alpha .
\end{aligned}
\]

From 579.png
\(\ast \)<b>88\(\cdot \)14</b>\(\ldotp ~~\vdash\colon\ldotp \kappa \subset A'P\ldotp \supset :P\upharpoonright \kappa \epsilon \text{Rel Mult}\ldotp \equiv \ldotp \exists !P_{\Delta }'\kappa \)

<i>Dem</i>.
\[
\begin{aligned}
&\vdash\ldotp \ast 80\cdot 23\ldotp \supset \vdash:\exists !P_{\Delta }'\kappa \ldotp \equiv \ldotp \exists !(P\upharpoonright \kappa )_{\Delta }'\kappa \quad (1)\\
&\vdash\ldotp \ast 35\cdot 65\ldotp \supset \vdash:\kappa \subset A'P\ldotp \supset \ldotp A'(P\upharpoonright \kappa )=\kappa \quad (2)\\
&\vdash\ldotp (1)\ldotp (2)\ldotp \supset \vdash\colon\ldotp \text{Hp}\ldotp \supset :\exists !P_{\Delta }'\kappa \ldotp \equiv \ldotp \exists !(P\upharpoonright \kappa )_{\Delta }'A'(P\upharpoonright \kappa )\ldotp\\
&[\ast 88\cdot 1] \qquad \equiv \ldotp P\upharpoonright \kappa \epsilon \text{Rel Mult}\colon\ldotp\supset \vdash\ldotp \text{Prop}
\end{aligned}
\]

I see now the error happens once (per project page I think). I got the error, clicked exit to close preview, then clicked preview again. The second time entering preview, it showed the formatted math properly with no error.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this is still ok with MathJax 4? From Upgrading from v3 to v4:

If you are calling the MathJax API, then you may need to change to using the promise-based calls like MathJax.typesetPromise() rather than the synchronous ones like MathJax.typeset(). See the MathJax v4.0 and Promises section for details and suggestions for how to proceed.

Update: I tried the sandbox. For the first thing I tried, I got this error:

MathJax error: Error: MathJax retry -- an asynchronous action is required; try using one of the promise-based functions and await its resolution.

Good point, I can't look at this till next month but feel free to change it if like

@cpeel cpeel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requires update before it can be merged.

@cpeel

cpeel commented Jul 29, 2026

Copy link
Copy Markdown
Member

Resolved by #1599

@cpeel cpeel closed this Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants