-
Notifications
You must be signed in to change notification settings - Fork 11
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
Use katex_js_path when pre-rendering #128
Conversation
@kalvdans can you take a look at the proposed changes, and check if this would work for you. |
I will check, give me an hour or two. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! The patch works out-of-the box for my usecase, pointing to the system-wide installation of katex.
Just commenting some minor comments on certain rows. Additional minor comments:
-
The error handling is ugly when path doesn't exist. (says: Please also report this if it was a user error, so that a better error message can be provided next time.)
-
"Relates to" can be changed to "Fixes" in the PR title (unless you want to keep the issue open until release)
sphinxcontrib/katex.py
Outdated
# Path to KaTeX javascript file | ||
KATEX_PATH = None | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not use capitals for variables.
# Path to KaTeX javascript file | |
KATEX_PATH = None | |
# Path to KaTeX javascript file, or None if the bundled should be used. | |
katex_path = None | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed all class variables of KaTeXServer
to use lower case letters.
Co-authored-by: kalvdans <github@kalvdans.no-ip.org>
I only used "Relates" and not "Fixed" yet, as you were also concerned about |
I'm happy with the configurability of katex css, but let's discuss that further in the issue. |
Turns our the relative path doesn't work in Ubuntu 22.04, only in Ubuntu 24.04.
strace shows it tries to open Ubuntu 22.04 have nodejs v12.22.9 while Ubuntu 24.04 have v18.19.1. |
Thanks for pointing this out. I will try to fix this tomorrow and add a test for it. |
I updated the code slightly and added a few tests for it, but it might be that there is no simple solution for cases in which the relative path fails for nodejs, compare https://blog.spencersnyder.io/solving-the-long-relative-paths-problem-natively-in-node-js-6aeebc3a81bd. |
The mystery is solved, turns out my current working directory when I tested on Ubuntu 24.04 was by luck exactly the same level deep as
With your changes to make the path relative to SRC_DIR instead of current working directory it works fine for me. Our CI passes with the lastest version (bc0db1f5) of this PR. Thanks a lot for the fix! |
Relates to #122
This uses the value from
katex_js_path
for the path to the KaTeX executable, used insidekatex-server.js
to render the pages in pre-render mode. The default value ofkatex_js_path
points to the KaTeX Javascript library bundled with this extension, but the user can point to another file on the local machine.