-
-
Notifications
You must be signed in to change notification settings - Fork 261
fix: dynamic injected stylesheets with fonts #350
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
base: dev
Are you sure you want to change the base?
Conversation
|
Perhaps we could solve this problem more universally by introducing a new Plugin Hook like I'm not entirely sure, this might increase complexity, but in the future if others have similar needs, they won't need to frequently submit PRs to the repository. GPT's answer about introducing a new Plugin Hook like Details
From a technical perspective, the existing Plugin mechanism cannot directly solve this problem for the following reasons: Why Plugins Cannot Solve This
If Implementing Through Plugin Mechanism ExtensionThe following major changes would be required:
Difficulty Assessment
ConclusionThe current direct fix solution (adding
The Plugin mechanism is more suitable for handling optional, user-specific extension features rather than fixing bugs in core functionality. |
|
Hi @ZiuChen thank you for this proposal! I think MathJax is working good without using need to embed special fonts. AS you know I'm still stuck with my moving but please point this PR to dev branch |
|
Of course, I have changed the target branch to the dev branch. Please review the code at your convenience. The temporary solution is to patch snapdom (this is what I'm currently doing). But in the long term, I hope to introduce a similar whitelist mechanism, because there will definitely be users who inject font support libraries like KateX through CDN addresses. Best regards :D |
f7062f8 to
bcb719a
Compare
…tylesheets - Added unit tests for KaTeX and MathJax font support
|
GPT has provided the implementation for the new Plugin Hook feature. |
|
@tinchox5 Can we merge this PR? |
|
Sorry! I had just landed in NYC and I need time to settle down |
This pull request adds targeted support for detecting and embedding fonts from popular math rendering libraries such as KaTeX and MathJax. The main change is the improved ability to recognize stylesheets from these libraries as font providers, ensuring that their fonts are properly embedded even when loaded from various CDNs. The update also introduces comprehensive tests to verify this behavior for multiple CDN sources.
Font detection improvements:
FONT_LIBRARIEStosrc/modules/fonts.jsthat lists common libraries (katex,mathjax,mathml) known to provide web fonts.isLikelyFontStylesheetfunction insrc/modules/fonts.jsto recognize stylesheets from these libraries by checking the stylesheet path for library names, improving cross-origin font detection for math rendering libraries.Testing enhancements:
__tests__/module.fonts.katex.test.jsto verify that KaTeX and MathJax fonts are correctly detected and embedded from multiple CDN sources, addressing issue Capturing screenshots of DOM elements containing KateX formulas, the output image lacks proper font styling in the formulas. #344 and preventing regressions.Fixed: #344