summaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authorArun Isaac <arunisaac@systemreboot.net>2017-06-03 01:57:51 +0530
committerArun Isaac <arunisaac@systemreboot.net>2017-06-05 19:16:06 +0530
commita3d3b7a4e137ce977852342d75125279cf0ca41f (patch)
tree6e7a0f6c2ac262acf83939e236020dbd26e424a9 /gnu
parent6bce59552fa46b3b7773229fb014a3f2510f9734 (diff)
downloadpatches-a3d3b7a4e137ce977852342d75125279cf0ca41f.tar
patches-a3d3b7a4e137ce977852342d75125279cf0ca41f.tar.gz
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')
-rw-r--r--gnu/local.mk1
-rw-r--r--gnu/packages/javascript.scm85
2 files changed, 86 insertions, 0 deletions
diff --git a/gnu/local.mk b/gnu/local.mk
index 0722217ac4..4b2bdfe37a 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -208,6 +208,7 @@ GNU_SYSTEM_MODULES = \
%D%/packages/irc.scm \
%D%/packages/iso-codes.scm \
%D%/packages/java.scm \
+ %D%/packages/javascript.scm \
%D%/packages/jemalloc.scm \
%D%/packages/jrnl.scm \
%D%/packages/julia.scm \
diff --git a/gnu/packages/javascript.scm b/gnu/packages/javascript.scm
new file mode 100644
index 0000000000..6746ad1d22
--- /dev/null
+++ b/gnu/packages/javascript.scm
@@ -0,0 +1,85 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2017 Arun Isaac <arunisaac@systemreboot.net>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages javascript)
+ #:use-module ((guix licenses) #:prefix license:)
+ #:use-module (gnu packages)
+ #:use-module (gnu packages base)
+ #:use-module (gnu packages compression)
+ #:use-module (gnu packages fonts)
+ #:use-module (gnu packages lisp)
+ #:use-module (guix packages)
+ #:use-module (guix download)
+ #:use-module (guix build-system trivial))
+
+(define-public js-mathjax
+ (package
+ (inherit font-mathjax)
+ (name "js-mathjax")
+ (arguments
+ `(#:modules ((guix build utils))
+ #:builder
+ (begin
+ (use-modules (guix build utils)
+ (ice-9 match)
+ (ice-9 popen)
+ (ice-9 regex))
+ (set-path-environment-variable
+ "PATH" '("bin") (map (match-lambda
+ ((_ . input)
+ input))
+ %build-inputs))
+ (set-path-environment-variable
+ "GUIX_LOCPATH" '("lib/locale")
+ (list (assoc-ref %build-inputs "glibc-utf8-locales")))
+ (setenv "LANG" "en_US.UTF-8")
+ (let ((install-directory (string-append %output "/share/javascript/mathjax")))
+ (system* "tar" "xvf" (assoc-ref %build-inputs "source")
+ "MathJax-2.7.1/unpacked" "--strip" "2")
+ (mkdir-p install-directory)
+ (symlink (string-append (assoc-ref %build-inputs "font-mathjax")
+ "/share/fonts/mathjax")
+ (string-append install-directory "/fonts"))
+
+ (for-each
+ (lambda (file)
+ (let ((installed (string-append install-directory
+ ;; remove prefix "."
+ (string-drop file 1))))
+ (format #t "~a -> ~a~%" file installed)
+ (cond
+ ((string-match "\\.js$" file)
+ (mkdir-p (dirname installed))
+ (let ((minified (open-pipe* OPEN_READ "uglify-js" file)))
+ (call-with-output-file installed
+ (lambda (port)
+ (dump-port minified port)))))
+ (else
+ (install-file file (dirname installed))))))
+ (find-files "."))))))
+ (native-inputs
+ `(("font-mathjax" ,font-mathjax)
+ ("glibc-utf8-locales" ,glibc-utf8-locales)
+ ("uglify-js" ,uglify-js)
+ ,@(package-native-inputs font-mathjax)))
+ (synopsis "JavaScript display engine for LaTeX, MathML, and AsciiMath")
+ (description "MathJax is a JavaScript display engine for LaTeX, MathML,
+and AsciiMath notation that works in all modern browsers. It requires no
+plugins or software to be installed on the browser. So the page author can
+write web documents that include mathematics and be confident that readers will
+be able to view it naturally and easily.")))