Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make sure mathjax will be bundled #2821

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions frontend-bundler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"scripts": {
"start": "cd ../frontend && parcel --dist-dir ../frontend-dist --config ../frontend-bundler/.parcelrc editor.html index.html error.jl.html",
"build": "cd ../frontend && parcel build --no-source-maps --public-url . --dist-dir ../frontend-dist --config ../frontend-bundler/.parcelrc editor.html index.html error.jl.html && node ../frontend-bundler/add_sri.js ../frontend-dist/editor.html",
"clean": "rm -rf ../frontend/.parcel-cache/",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
Expand Down
9 changes: 7 additions & 2 deletions frontend/common/SetupMathJax.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,19 @@ export const setup_mathjax = () => {
requestIdleCallback(
() => {
console.log("Loading mathjax!!")
const src = new URL("https://cdn.jsdelivr.net/npm/[email protected]/es5/tex-svg-full.js", import.meta.url)
const integrity = "sha384-4kE/rQ11E8xT9QgrCBTyvenkuPfQo8rXYQvJZuMgxyPOoUfpatjQPlgdv6V5yhUK"
const script = document.head.querySelector("#MathJax-script")
script?.addEventListener("load", () => {
if (!script) return
script.addEventListener("load", () => {
console.log("MathJax loaded!")
if (window["MathJax"]?.version !== "3.2.2") {
twowasloaded()
}
})
script.setAttribute("src", script.getAttribute("not-the-src-yet"))
script.setAttribute("crossorigin", "anonymous")
if (!import.meta.url.startsWith("file:///")) script.setAttribute("integrity", integrity)
script.setAttribute("src", src.toString())
},
{ timeout: 2000 }
)
Expand Down
4 changes: 2 additions & 2 deletions frontend/editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
<script src="./editor.js" type="module" defer></script>
<script src="./warn_old_browsers.js"></script>

<!-- This script will be enabled by JS after the notebook has initialized to prevent taking up bandwidth during the initial load. -->
<script type="text/javascript" id="MathJax-script" integrity="sha384-4kE/rQ11E8xT9QgrCBTyvenkuPfQo8rXYQvJZuMgxyPOoUfpatjQPlgdv6V5yhUK" crossorigin="anonymous" not-the-src-yet="https://cdn.jsdelivr.net/npm/[email protected]/es5/tex-svg-full.js" async></script>
<!-- This script will be enabled by JS after the notebook has initialized to prevent taking up bandwidth during the initial load. Update the version there. -->
<script type="text/javascript" id="MathJax-script" async></script>
</head>

<body class="loading no-MαθJax">
Expand Down
Loading