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

Detect when MathJax 2 was loaded before Pluto tries to load MathJax 3 #2803

Merged
merged 1 commit into from
Feb 7, 2024
Merged
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
15 changes: 14 additions & 1 deletion frontend/common/SetupMathJax.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ export const setup_mathjax = () => {
}
setup_done = true

const deprecated = () => console.warn("Pluto uses MathJax 3, but a MathJax 2 function was called.")
const deprecated = () =>
console.error(
"Pluto.jl: Pluto loads MathJax 3 globally, but a MathJax 2 function was called. The two version can not be used together on the same web page."
)
const twowasloaded = () =>
console.error(
"Pluto.jl: MathJax 2 is already loaded in this page, but Pluto wants to load MathJax 3. Packages that import MathJax 2 in their html display will break Pluto's ability to render latex."
)

// @ts-ignore
window.MathJax = {
Expand Down Expand Up @@ -69,6 +76,12 @@ export const setup_mathjax = () => {
() => {
console.log("Loading mathjax!!")
const script = document.head.querySelector("#MathJax-script")
script?.addEventListener("load", () => {
console.log("MathJax loaded!")
if (window["MathJax"]?.version !== "3.2.2") {
twowasloaded()
}
})
script.setAttribute("src", script.getAttribute("not-the-src-yet"))
},
{ timeout: 2000 }
Expand Down
Loading