diff options
| author | Arun Isaac <arunisaac@systemreboot.net> | 2017-06-03 01:57:51 +0530 |
|---|---|---|
| committer | Arun Isaac <arunisaac@systemreboot.net> | 2017-06-05 19:16:06 +0530 |
| commit | a3d3b7a4e137ce977852342d75125279cf0ca41f (patch) | |
| tree | 6e7a0f6c2ac262acf83939e236020dbd26e424a9 /gnu/packages/javascript.scm | |
| parent | 6bce59552fa46b3b7773229fb014a3f2510f9734 (diff) | |
gnu: Add js-mathjax.
* gnu/packages/javascript.scm: New file.
* gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
* gnu/packages/javascript.scm (js-mathjax): New variable.
Diffstat (limited to 'gnu/packages/javascript.scm')
| -rw-r--r-- | gnu/packages/javascript.scm | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/gnu/packages/javascript.scm b/gnu/packages/javascript.scm new file mode 100644 index 00000000000..6746ad1d224 --- /dev/null +++ b/gnu/packages/javascript.scm | |||
| @@ -0,0 +1,85 @@ | |||
| 1 | ;;; GNU Guix --- Functional package management for GNU | ||
| 2 | ;;; Copyright © 2017 Arun Isaac <arunisaac@systemreboot.net> | ||
| 3 | ;;; | ||
| 4 | ;;; This file is part of GNU Guix. | ||
| 5 | ;;; | ||
| 6 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | ||
| 7 | ;;; under the terms of the GNU General Public License as published by | ||
| 8 | ;;; the Free Software Foundation; either version 3 of the License, or (at | ||
| 9 | ;;; your option) any later version. | ||
| 10 | ;;; | ||
| 11 | ;;; GNU Guix is distributed in the hope that it will be useful, but | ||
| 12 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | ;;; GNU General Public License for more details. | ||
| 15 | ;;; | ||
| 16 | ;;; You should have received a copy of the GNU General Public License | ||
| 17 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | ||
| 18 | |||
| 19 | (define-module (gnu packages javascript) | ||
| 20 | #:use-module ((guix licenses) #:prefix license:) | ||
| 21 | #:use-module (gnu packages) | ||
| 22 | #:use-module (gnu packages base) | ||
| 23 | #:use-module (gnu packages compression) | ||
| 24 | #:use-module (gnu packages fonts) | ||
| 25 | #:use-module (gnu packages lisp) | ||
| 26 | #:use-module (guix packages) | ||
| 27 | #:use-module (guix download) | ||
| 28 | #:use-module (guix build-system trivial)) | ||
| 29 | |||
| 30 | (define-public js-mathjax | ||
| 31 | (package | ||
| 32 | (inherit font-mathjax) | ||
| 33 | (name "js-mathjax") | ||
| 34 | (arguments | ||
| 35 | `(#:modules ((guix build utils)) | ||
| 36 | #:builder | ||
| 37 | (begin | ||
| 38 | (use-modules (guix build utils) | ||
| 39 | (ice-9 match) | ||
| 40 | (ice-9 popen) | ||
| 41 | (ice-9 regex)) | ||
| 42 | (set-path-environment-variable | ||
| 43 | "PATH" '("bin") (map (match-lambda | ||
| 44 | ((_ . input) | ||
| 45 | input)) | ||
| 46 | %build-inputs)) | ||
| 47 | (set-path-environment-variable | ||
| 48 | "GUIX_LOCPATH" '("lib/locale") | ||
| 49 | (list (assoc-ref %build-inputs "glibc-utf8-locales"))) | ||
| 50 | (setenv "LANG" "en_US.UTF-8") | ||
| 51 | (let ((install-directory (string-append %output "/share/javascript/mathjax"))) | ||
| 52 | (system* "tar" "xvf" (assoc-ref %build-inputs "source") | ||
| 53 | "MathJax-2.7.1/unpacked" "--strip" "2") | ||
| 54 | (mkdir-p install-directory) | ||
| 55 | (symlink (string-append (assoc-ref %build-inputs "font-mathjax") | ||
| 56 | "/share/fonts/mathjax") | ||
| 57 | (string-append install-directory "/fonts")) | ||
| 58 | |||
| 59 | (for-each | ||
| 60 | (lambda (file) | ||
| 61 | (let ((installed (string-append install-directory | ||
| 62 | ;; remove prefix "." | ||
| 63 | (string-drop file 1)))) | ||
| 64 | (format #t "~a -> ~a~%" file installed) | ||
| 65 | (cond | ||
| 66 | ((string-match "\\.js$" file) | ||
| 67 | (mkdir-p (dirname installed)) | ||
| 68 | (let ((minified (open-pipe* OPEN_READ "uglify-js" file))) | ||
| 69 | (call-with-output-file installed | ||
| 70 | (lambda (port) | ||
| 71 | (dump-port minified port))))) | ||
| 72 | (else | ||
| 73 | (install-file file (dirname installed)))))) | ||
| 74 | (find-files ".")))))) | ||
| 75 | (native-inputs | ||
| 76 | `(("font-mathjax" ,font-mathjax) | ||
| 77 | ("glibc-utf8-locales" ,glibc-utf8-locales) | ||
| 78 | ("uglify-js" ,uglify-js) | ||
| 79 | ,@(package-native-inputs font-mathjax))) | ||
| 80 | (synopsis "JavaScript display engine for LaTeX, MathML, and AsciiMath") | ||
| 81 | (description "MathJax is a JavaScript display engine for LaTeX, MathML, | ||
| 82 | and AsciiMath notation that works in all modern browsers. It requires no | ||
| 83 | plugins or software to be installed on the browser. So the page author can | ||
| 84 | write web documents that include mathematics and be confident that readers will | ||
| 85 | be able to view it naturally and easily."))) | ||
