Fix conflict in with KaTeX and Require.js #12493
Merged
Conversation
… needs to be context aware of require conflict - Require.js being loaded will trigger AMD detection for KaTeX, which prevents `widow.katex` to be defined - About KaTeX in browser: https://katex.org/docs/browser#module-loaders - About AMD in JS: https://github.com/amdjs/amdjs-api/wiki/AMD#defineamd-property-
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When
embed-resources: true, by default Math will evade embedding by adding back the JS script node in browser.However, KaTeX and Require.js does not play well together, and quarto does a postprocessing of HTML file to opt out require while loading KaTeX
quarto-cli/src/format/html/format-html-math.ts
Lines 11 to 36 in 2c6822c
This post-processing is not happening when
embed-resourcesis used, as we do insert a script that will dynamically append loading<script>to<head>.This is the script tweaked in this PR to be context-aware of
requireconflict.The opt-out is narrower than the post-processor to disable the AMD detection only, and enable it at the right time after the script is loaded.
widow.katexto be definedWe could probably do the same but I didn't in this PR as tests are passing like this.
fixes #10113