Repository navigation
chore(deps): upgrade to wagtail-polymath 2 and MathJax 4 - #879
kevinhowbrook wants to merge 12 commits into
Conversation
|
This PR is being prevented from merging because you have added one of our blocking labels: do not merge, status: Blocked You'll need to remove it before this PR can be merged. |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as outdated.
This comment was marked as outdated.
| // MathJax on the ONS CDN instead. | ||
| window.MathJax.loader = { | ||
| ...window.MathJax.loader, | ||
| paths: { ...window.MathJax.loader?.paths, fonts: '[mathjax]/fonts' }, |
There was a problem hiding this comment.
q: would the fonts loader trick work with the defaults too? If so, we could make that change in the library
There was a problem hiding this comment.
Looking into this - it might be worth defining an extra config dict polymath side - meaning I wouldn't have to do some juggling I'm doing in this pr, e.g
WAGTAIL_POLYMATH = {
"engine": "mathjax",
"libraries": [{"url": ".../4.1.3/tex-mml-chtml.js", "sri": "..."}],
"mathjax_fonts_url": f"{ONS_CDN_URL}/vendor/mathjax/4.1.3/fonts", # optional
... and perhaps speech/braille settings true/flase
}
There was a problem hiding this comment.
An idea here wagtail-nest/wagtail-polymath#38
b8e7bf5 to
2f8f8c1
Compare
MathJax 4 generates speech and braille in a blob: web worker, which our CSP blocks. Turn them off and keep assistive MathML on for screen readers. Not a regression: on MathJax 2.7.9, assistive MathML was the default, speech was opt-in only and its speech rules were already blocked by our connect-src, and braille did not exist.
2f8f8c1 to
c7fdc56
Compare
|
Some CI failures here are expected because the ons cdn vendor needs publishing |
Replaces the fixed 5 second wait after filling in the equation with an assertion that the polymath preview shows a typeset equation.
There was a problem hiding this comment.
This exists to adjust polymath's MathJax config, in the admin and on the front end:
- fonts load from the ONS CDN instead of jsdelivr
- speech and braille are off, because MathJax 4 runs them in a
blob:worker (not CSP friendly.
This can go once polymath can take the config itself (wagtail-nest/wagtail-polymath#38). More detail is in docs/custom-features/equations.md.
|
Marking as blocked for the moment, mostly because the CDN isn't published yet so the tests cannot pass, and ideally it would be nice to address wagtail-nest/wagtail-polymath#38 (that's not a blocker per se though) |
What is the context of this PR?
This PR upgrades
wagtailmath1.4 towagtail-polymath2.0.3, which moves equations from using MathJax 2.7.9 to MathJax 4.1.3.MathJax 4 is served from the ONS CDN: ONSdigital/cdn.ons.gov.uk-vendor#54 added MathJax 4.1.3 and its font package. That PR is merged, but waiting on deployment (it deployed fine last time - I've no idea why it's 404ing still)
Upstream issues raised during this upgrade
srcinstead ofhref, so the Katex stylesheet never loads wagtail-nest/wagtail-polymath#33: KaTeX stylesheet never loaded (Update design system to 72.1.0 #34)all fixed in polymath 2.0.3
How to review
MathJax 4 isn't up on
cdn.ons.gov.ukyet, so maybe wait for that, or locally serve the vendor repo (see below).main, create or find a page with a few equation blocks, so you can check existing contentsurvives the upgrade. For example:
$$\bar{x} = \frac{1}{n}\sum_{i=1}^{n} x_i$$(display)\(E = mc^2\)(inline)\[a + b = c\](display)poetry install(swapswagtailmathforwagtail-polymath2.0.3).Serving the vendor repo locally until the CDN is live
In a checkout of ONSdigital/cdn.ons.gov.uk-vendor
main, serve it with CORS on port 8001:Then point dis-wagtail at it in
cms/settings/local.py(after step 3, becausemainuses a differentWAGTAIL_POLYMATHformat):Deployment Safety
Bleed and Sandbox deploy automatically on merge, so PRs should be safe to deploy immediately.
Please select one:
Blocked on the CDN.
https://cdn.ons.gov.uk/vendor/mathjax/4.1.3/tex-mml-chtml.jsmust 200 before this can merge. Once it does, then this is OK to auto deploy.Follow-up Actions
check without local overrides
NWP Confluence folder
Ticket: CMS-1419