summary refs log tree commit diff
path: root/gnu/packages/javascript.scm
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2022-06-13 12:41:33 +0200
committerRicardo Wurmus <rekado@elephly.net>2022-06-13 12:43:31 +0200
commit7846896156da7ec45a3a3f5566b2a12c8ed3472b (patch)
tree64d8b5cf4dfeb7e86f68954c469379b2f8e85d25 /gnu/packages/javascript.scm
parent97ebfc8f5c829b1a069f73395d6ffaf2d8096f5f (diff)
downloadguix-7846896156da7ec45a3a3f5566b2a12c8ed3472b.tar.gz
gnu: Add js-mathjax-for-r-mathjaxr.
* gnu/packages/patches/mathjax-3.1.2-no-a11y.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
* gnu/packages/javascript.scm (js-mathjax-for-r-mathjaxr): New variable.
Diffstat (limited to 'gnu/packages/javascript.scm')
-rw-r--r--gnu/packages/javascript.scm57
1 files changed, 57 insertions, 0 deletions
diff --git a/gnu/packages/javascript.scm b/gnu/packages/javascript.scm
index 028b5c4391..5598341e5c 100644
--- a/gnu/packages/javascript.scm
+++ b/gnu/packages/javascript.scm
@@ -313,6 +313,63 @@ be able to view it naturally and easily.")))
     (description (package-description js-mathjax))
     (license license:asl2.0)))
 
+(define-public js-mathjax-for-r-mathjaxr
+  (package
+    (inherit js-mathjax-3)
+    (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"))
+       (patches (search-patches "mathjax-disable-webpack.patch"
+                                "mathjax-3.1.2-no-a11y.patch"))))
+    (arguments
+     (substitute-keyword-arguments (package-arguments js-mathjax-3)
+       ((#:phases phases '%standard-phases)
+        `(modify-phases ,phases
+           (replace 'prepare-sources
+             (lambda* (#:key inputs #:allow-other-keys)
+               ;; All a11y components depend on speech-rule-engine, which cannot be
+               ;; built from source. Since this only affects accessibility, remove them.
+               (delete-file-recursively "ts/a11y")
+               (delete-file-recursively "components/src/a11y")
+               (delete-file-recursively "components/src/sre")
+               (delete-file-recursively "components/src/node-main")
+
+               ;; Copy sources of dependencies, so we can create symlinks.
+               (mkdir-p "node_modules")
+               (with-directory-excursion "node_modules"
+                 (for-each
+                  (lambda (p)
+                    (copy-recursively (assoc-ref inputs (string-append "node-" p)) p))
+                  '("mj-context-menu")))
+
+               ;; Make sure esbuild can find imports. This way we don’t have to rewrite files.
+               (symlink "ts" "js")
+               (symlink "ts" "node_modules/mj-context-menu/js")))))))
+    (native-inputs
+     `(("esbuild" ,esbuild)
+       ("node" ,node-lts)
+       ("node-mj-context-menu"
+        ,(let ((name "context-menu")
+               (version "0.6.1"))
+           (origin
+             (method git-fetch)
+             (uri (git-reference
+                    (url "https://github.com/zorkow/context-menu.git")
+                    (commit (string-append "v" version))))
+             (file-name (git-file-name name version))
+             (sha256
+              (base32
+               "1q063l6477z285j6h5wvccp6iswvlp0jmb96sgk32sh0lf7nhknh")))))))))
+
 (define-public js-commander
   (package
     (name "js-commander")