Debian bookwormでJupyter Notebookを最近使うようになったのですが、エクスポートしたHTMLを他環境で開くと数式展開されないという問題に出くわしました。調べてみるとdebパッケージでインストールしているnbconvertのバージョンが古く、ローカルのJavaScriptを参照するようエクスポートする仕様が原因とわかりました。
$ dpkg -s jupyter-nbconvert | grep -iw version Version: 6.5.3-3
Github上の最新バージョン(7.16.4)に記載されているスクリプトパスに書き換えると、エクスポートしたHTMLを他環境で開いても数式展開されるようになりました。差分を以下に示します。
matsuba@debian:/usr/lib/python3/dist-packages/nbconvert/exporters$ diff -uw html.py{.old,}
--- html.py.old 2023-01-19 06:21:23.000000000 +0900
+++ html.py 2024-06-04 21:02:18.227082093 +0900
@@ -100,29 +100,29 @@
)
require_js_url = Unicode(
- "file:///usr/share/javascript/requirejs/require.min.js",
+ "https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.min.js",
help="""
URL to load require.js from.
- Defaults to loading from local directory.
+ Defaults to loading from cdnjs.
""",
).tag(config=True)
mathjax_url = Unicode(
- "file:///usr/share/javascript/mathjax/MathJax.js?config=TeX-AMS_CHTML-full,Safe",
+ "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/latest.js?config=TeX-AMS_CHTML-full,Safe",
help="""
URL to load Mathjax from.
- Defaults to loading from local directory.
+ Defaults to loading from cdnjs.
""",
).tag(config=True)
jquery_url = Unicode(
- "file:///usr/share/javascript/jquery/jquery.min.js",
+ "https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js",
help="""
URL to load jQuery from.
- Defaults to loading from local directory.
+ Defaults to loading from cdnjs.
""",
).tag(config=True)