license:lgpl2.0)))))
 
+(define-public js-mathjax-3
+  (package
+    (name "js-mathjax")
+    (version "3.1.2")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+              (url "https://github.com/mathjax/MathJax-src")
+              (commit version)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32
+         "0kqcb6pl0zfs4hf8zqb4l50kkfq7isv35vpy05m0lg0yr9w0w4ai"))))
+    (build-system trivial-build-system)
+    (arguments
+     `(#:modules ((guix build utils))
+       #:builder
+       (begin
+         (use-modules (guix build utils)
+                      (ice-9 match))
+         (set-path-environment-variable
+          "PATH" '("bin") (map (match-lambda
+                                 ((_ . input)
+                                  input))
+                               %build-inputs))
+         (copy-recursively (assoc-ref %build-inputs "source")
+                           "source")
+         (chdir "source")
+
+         ;; TODO: we can't build this because it depends on
+         ;; speech-rule-engine.
+         ;;(delete-file-recursively "ts/a11y")
+         (delete-file-recursively "components/src/a11y")
+         
+         ;;(delete-file-recursively "components/src/sre")
+         ;; This file copies a11y files, which we don't build (see above).
+         (delete-file "components/src/node-main/copy.json")
+
+         (substitute* '("components/bin/build"
+                        "components/bin/pack"
+                        "components/bin/copy"
+                        "components/bin/makeAll")
+           (("/usr/bin/env node")
+            (which "node")))
+
+         ;; Make the compiled files of the context menu available. 
+         (mkdir-p "mj-context-menu/js")
+         (copy-recursively (string-append (assoc-ref %build-inputs "js-context-menu")
+                                          "/share/javascript/context-menu")
+                           "mj-context-menu/js")
+
+         (let ((esbuild (string-append (assoc-ref %build-inputs "esbuild")
+                                       "/bin/esbuild"))
+               (node (string-append (assoc-ref %build-inputs "node")
+                                    "/bin/node"))
+               (target (string-append %output "/share/javascript/mathjax")))
+
+           ;; Transpile TypeScript
+           (apply invoke esbuild
+                  "--bundle"
+                  "--tsconfig=tsconfig.json"
+                  "--platform=node"
+                  "--outdir=js"
+                  (find-files "ts" "\\.ts$"))
+
+           (setenv "HOME" "/tmp")
+           (with-directory-excursion "components"
+             ;; This requires network access
+             (substitute* "bin/makeAll"
+               (("processDir\\(fulldir, webpackLib\\);") ""))
+             (invoke node "bin/makeAll" "src"))
+
+           ;; Build components
+           (invoke esbuild
+                   "components/src/tex-chtml-full/tex-chtml-full.js"
+                   "--bundle"
+                   "--minify"
+                   "--platform=node"
+                   (string-append "--outfile=" target "/es5/mml-chtml.js"))))))
+    (native-inputs
+     `(("esbuild" ,esbuild)
+       ("node" ,node-10.22)
+       ("js-context-menu" ,js-context-menu)))
+    (home-page "https://www.mathjax.org/")
+    (synopsis "TODO")
+    (description "TODO")
+    (license license:asl2.0)))
+

Generated by Ricardo Wurmus using scpaste at Sun Nov 28 12:43:06 2021. UTC. (original)