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: Wypst rendering on iOS Obsidian #11

Merged
merged 1 commit into from
May 12, 2024

Conversation

haruleekim
Copy link
Contributor

Wypst rendering does not work on iOS Obsidian - it is treated and rendered as if it were normal Latex code.

This is because this plugin encountered an error referencing MathJax's rendering handler, and failed to replace it with Wypst's.

On some platforms, including iOS, the top-level object that can be referenced from Javascript appears to be window rather than global.

Therefore, I changed the way this plugin references the MathJax object from global.MathJax to globalThis.MathJax to make it platform-independent, and found that it works fine on both the Chromium-based Electron on MacOS and the WebKit view on iOS.

@0xpapercut
Copy link
Owner

Thank you. I reference the Mozilla documentation:

Historically, accessing the global object has required different syntax in different JavaScript environments. On the web you can use window, self, or frames - but in Web Workers only self will work. In Node.js none of these work, and you must instead use global. The this keyword could be used inside functions running in non–strict mode, but this will be undefined in modules and inside functions running in strict mode. You can also use Function('return this')(), but environments that disable eval(), like CSP in browsers, prevent use of Function in this way.

so it would appear that this is indeed a cross compatible functionality.

@0xpapercut 0xpapercut merged commit 22f50cc into 0xpapercut:master May 12, 2024
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.

2 participants