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 and use system MathJax-3.x #36098

Merged
merged 4 commits into from
Aug 27, 2023
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions build/pkgs/mathjax/distros/gentoo.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
>=dev-libs/mathjax-3
26 changes: 26 additions & 0 deletions build/pkgs/mathjax/spkg-configure.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
SAGE_SPKG_CONFIGURE([mathjax], [
# Arch: /usr/share/mathjax
# Gentoo: /usr/share/mathjax
# Void: /usr/share/mathjax
AC_MSG_CHECKING([for MathJax-3.x])
m4_foreach([mathjax_dir], [/usr/share/mathjax], [
# tex-chtml.hs is used in src/sage_docbuild/conf.py
# and was not present in MathJax-2.x
AS_IF([test -f "mathjax_dir/tex-chtml.js"], [
SAGE_MATHJAX_DIR="mathjax_dir"
AC_MSG_RESULT([mathjax_dir])
])
])
AS_IF([test -z "${SAGE_MATHJAX_DIR}"], [
AC_MSG_RESULT([no])
sage_spkg_install_mathjax=yes
])
],[],[],[
# post-check
AS_IF([test x$sage_spkg_install_mathjax = xyes], [
# Our spkg-src script adds an extra "mathjax"
SAGE_MATHJAX_DIR='${prefix}'/share/mathjax/mathjax
])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems no easy fix. A trick is to add ".." to '${prefix}'/share/mathjax/mathjax here so that we use ".." to indicate that this is an spkg mathjax, and then use the indicator to differentiate how to tell sphinx where to find mathjax in conf.py. Yes, this is ugly...


AC_SUBST(SAGE_MATHJAX_DIR, "${SAGE_MATHJAX_DIR}")
])
2 changes: 1 addition & 1 deletion pkgs/sage-conf/_sage_conf/_conf.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ SAGE_ARCHFLAGS = "@SAGE_ARCHFLAGS@"
SAGE_PKG_CONFIG_PATH = "@SAGE_PKG_CONFIG_PATH@".replace('$SAGE_LOCAL', SAGE_LOCAL)

# Used in sage.repl.ipython_kernel.install
MATHJAX_DIR = SAGE_LOCAL + "/share/mathjax"
MATHJAX_DIR = "@SAGE_MATHJAX_DIR@".replace('${prefix}', SAGE_LOCAL)
THREEJS_DIR = SAGE_LOCAL + "/share/threejs-sage"

# OpenMP flags, if available.
Expand Down
3 changes: 1 addition & 2 deletions src/sage_docbuild/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,7 @@ def set_intersphinx_mappings(app, config):
if os.environ.get('SAGE_USE_CDNS', 'no') == 'yes':
mathjax_path = "https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"
else:
Copy link
Collaborator

@kwankyu kwankyu Aug 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An "easy" fix would be to cut out the last path component of MATHJAX_DIR and prepend it to tex-chtml.js to make up mathjax_path.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean the lines L377,378.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. This would not work...

mathjax_path = 'mathjax/tex-chtml.js'
html_common_static_path += [MATHJAX_DIR]
mathjax_path = os.path.join(MATHJAX_DIR, 'tex-chtml.js')

# A list of glob-style patterns that should be excluded when looking for source
# files. They are matched against the source file names relative to the
Expand Down
Loading