GNU bug report logs - #27049
[PATCH] gnu: Add mathjax.

Previous Next

Package: guix-patches;

Reported by: Arun Isaac <arunisaac <at> systemreboot.net>

Date: Tue, 23 May 2017 21:44:01 UTC

Severity: normal

Tags: patch

Done: Arun Isaac <arunisaac <at> systemreboot.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 27049 in the body.
You can then email your comments to 27049 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#27049; Package guix-patches. (Tue, 23 May 2017 21:44:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Arun Isaac <arunisaac <at> systemreboot.net>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Tue, 23 May 2017 21:44:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Arun Isaac <arunisaac <at> systemreboot.net>
To: guix-patches <at> gnu.org
Cc: Arun Isaac <arunisaac <at> systemreboot.net>
Subject: [PATCH] gnu: Add mathjax.
Date: Wed, 24 May 2017 03:13:26 +0530
* gnu/packages/web.scm (mathjax): New variable.
---
 gnu/packages/web.scm | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/gnu/packages/web.scm b/gnu/packages/web.scm
index bcc20bfdd..84fa3c12f 100644
--- a/gnu/packages/web.scm
+++ b/gnu/packages/web.scm
@@ -4584,3 +4584,43 @@ allocations, it does not buffer data, it can be interrupted at anytime.
 Depending on your architecture, it only requires about 40 bytes of data per
 message stream (in a web server that is per connection).")
     (license l:expat)))
+
+(define-public mathjax
+  (package
+    (name "mathjax")
+    (version "2.7.1")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append
+             "https://github.com/mathjax/MathJax/archive/"
+             version ".tar.gz"))
+       (file-name (string-append name "-" version ".tar.gz"))
+       (sha256
+        (base32
+         "0sbib5lk0jrvbq6s72ag6ss3wjlz5wnk07ddxij1kp96yg3c1d1b"))))
+    (build-system trivial-build-system)
+    (arguments
+     `(#:modules ((guix build utils))
+       #:builder
+       (begin
+         (use-modules (guix build utils))
+
+         (let ((install-dir (string-append %output "/share/webapps/mathjax"))
+               (tar (string-append (assoc-ref %build-inputs "tar") "/bin/tar"))
+               (path (string-append (assoc-ref %build-inputs "gzip") "/bin")))
+           (mkdir-p install-dir)
+           (chdir install-dir)
+           (setenv "PATH" path)
+           (system* tar "xvf" (assoc-ref %build-inputs "source") "--strip" "1")))))
+    (native-inputs
+     `(("gzip" ,gzip)
+       ("tar" ,tar)))
+    (home-page "https://www.mathjax.org/")
+    (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.")
+    (license l:asl2.0)))
-- 
2.12.2





Information forwarded to guix-patches <at> gnu.org:
bug#27049; Package guix-patches. (Wed, 24 May 2017 10:10:01 GMT) Full text and rfc822 format available.

Message #8 received at 27049 <at> debbugs.gnu.org (full text, mbox):

From: Arun Isaac <arunisaac <at> systemreboot.net>
To: 27049 <at> debbugs.gnu.org
Subject: Re: bug#27049: Acknowledgement ([PATCH] gnu: Add mathjax.)
Date: Wed, 24 May 2017 15:39:44 +0530

> +         (let ((install-dir (string-append %output "/share/webapps/mathjax"))

I don't know if this is the correct path to install mathjax to. Do we
have any conventions/standards for this? Should I just put it in
/share/mathjax ?




Information forwarded to guix-patches <at> gnu.org:
bug#27049; Package guix-patches. (Wed, 24 May 2017 13:17:01 GMT) Full text and rfc822 format available.

Message #11 received at 27049 <at> debbugs.gnu.org (full text, mbox):

From: Brendan Tildesley <brendan.tildesley <at> openmailbox.org>
To: 27049 <at> debbugs.gnu.org
Subject: Re: bug#27049: Acknowledgement ([PATCH] gnu: Add mathjax.)
Date: Wed, 24 May 2017 23:16:34 +1000
Arun Isaac 於 2017-05-24 20:09 寫道:
>
>> +         (let ((install-dir (string-append %output "/share/webapps/mathjax"))
> I don't know if this is the correct path to install mathjax to. Do we
> have any conventions/standards for this? Should I just put it in
> /share/mathjax ?
>
>
>
I was wondering about this myself. Debian uses
/usr/share/javascript/mathjax, so I think we should use
/share/javascript/mathjax. a webapps directory implies that we intend to
categories "webapp" versus "non-webapp" packages, a functional
distinction that seems unimportant to the system as a whole. Debian has
a policy of naming JS packages like libjs-mathjax. On the other hand
Arch just calls it mathjax. Perhaps these things start to become an
issue once we have 20k+ packages, so I'm not sure there.

Once this is finalised, I can unbundle mathjax from Calibre, but then
the Calibre package will break if mathjax's path changes later on, so we
should sort this out now. Perhaps a way to solve it is to consider
future Javascript packages, and figure out what the most elegant way to
file them would be. I believe there are on the order of 100,000 JS
libraries out there in the wild, so I imagine we'll only be getting more
and more of them in due time. Perhaps a new gnu/packages/javascript.scm
file is ideal? After all, Mathjax is not just code for web browsers, but
is also used for MathML support in programs like Calibre's ebook-viewer.
Please take the time to think it through and set the convention for
future Javascript packages.





Information forwarded to guix-patches <at> gnu.org:
bug#27049; Package guix-patches. (Wed, 24 May 2017 14:48:02 GMT) Full text and rfc822 format available.

Message #14 received at 27049 <at> debbugs.gnu.org (full text, mbox):

From: Brendan Tildesley <brendan.tildesley <at> openmailbox.org>
To: 27049 <at> debbugs.gnu.org
Subject: Re: bug#27049: [PATCH] gnu: Add mathjax.
Date: Thu, 25 May 2017 00:47:09 +1000
Arun Isaac 於 2017-05-24 07:43 寫道:
> * gnu/packages/web.scm (mathjax): New variable.
> [...]
> +
> +         (let ((install-dir (string-append %output "/share/webapps/mathjax"))
> +               (tar (string-append (assoc-ref %build-inputs "tar") "/bin/tar"))
> +               (path (string-append (assoc-ref %build-inputs "gzip") "/bin")))
> +           (mkdir-p install-dir)
> +           (chdir install-dir)
> +           (setenv "PATH" path)
> +           (system* tar "xvf" (assoc-ref %build-inputs "source") "--strip" "1")))))
This is installing many extraneous files like .gitignore, .npmignore,
README.md, CONTRIBUTING, LICENSE, docs/, test/, latest.js. It may be
best start with an 'unpack phase, and then install the needed files to
the output directory.
This package is around 178MiB like it is, and most of that due to the
fonts. Would it be better to break this into two packages, mathjax, and
font-mathjax?

Additionally, programs like Icecat will not be able to find the fonts
unless they are under share/font*, so we should also install
mathjax/fonts/HTML-CSS/TeX/otf  to share/fonts/opentype/mathjax. I think
Guix should automatically take care of making that into a hardlink in
the store so it isn't duplicated, symlink when installed (everything is
already a symlink anyway in Guix)

[*] http://docs.mathjax.org/en/latest/installation.html




Information forwarded to guix-patches <at> gnu.org:
bug#27049; Package guix-patches. (Sun, 28 May 2017 17:42:02 GMT) Full text and rfc822 format available.

Message #17 received at 27049 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Brendan Tildesley <brendan.tildesley <at> openmailbox.org>
Cc: 27049 <at> debbugs.gnu.org
Subject: Re: bug#27049: [PATCH] gnu: Add mathjax.
Date: Sun, 28 May 2017 19:41:28 +0200
Hello,

Brendan Tildesley <brendan.tildesley <at> openmailbox.org> skribis:

> Arun Isaac 於 2017-05-24 07:43 寫道:
>> * gnu/packages/web.scm (mathjax): New variable.
>> [...]
>> +
>> +         (let ((install-dir (string-append %output "/share/webapps/mathjax"))
>> +               (tar (string-append (assoc-ref %build-inputs "tar") "/bin/tar"))
>> +               (path (string-append (assoc-ref %build-inputs "gzip") "/bin")))
>> +           (mkdir-p install-dir)
>> +           (chdir install-dir)
>> +           (setenv "PATH" path)
>> +           (system* tar "xvf" (assoc-ref %build-inputs "source") "--strip" "1")))))
> This is installing many extraneous files like .gitignore, .npmignore,
> README.md, CONTRIBUTING, LICENSE, docs/, test/, latest.js. It may be
> best start with an 'unpack phase, and then install the needed files to
> the output directory.
> This package is around 178MiB like it is, and most of that due to the
> fonts. Would it be better to break this into two packages, mathjax, and
> font-mathjax?

Also, Arun: is this package really source code?  Or does it contain
“minified” code and also bundles all its dependencies (which would not
be okay)?

Thanks,
Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#27049; Package guix-patches. (Sun, 28 May 2017 18:45:01 GMT) Full text and rfc822 format available.

Message #20 received at 27049 <at> debbugs.gnu.org (full text, mbox):

From: Arun Isaac <arunisaac <at> systemreboot.net>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: Brendan Tildesley <brendan.tildesley <at> openmailbox.org>,
 27049 <at> debbugs.gnu.org
Subject: Re: bug#27049: [PATCH] gnu: Add mathjax.
Date: Mon, 29 May 2017 00:14:28 +0530
Ludovic Courtès writes:

> Also, Arun: is this package really source code?  Or does it contain
> “minified” code and also bundles all its dependencies (which would not
> be okay)?

Good question! I had assumed it was the full source code without
checking carefully! I checked just now. The full source code is in the
"unpacked" directory of the tarball. The code in the top level directory
of the tarball is minified code. I think we should install only the
minified code to share/javascript/mathjax/.

And, like Brendan said, we should separate the fonts into a font-mathjax
package. And, these fonts should be symlinked into the js-mathjax
package.

I'm working on both packages. I'll send patches once they are ready.




Information forwarded to guix-patches <at> gnu.org:
bug#27049; Package guix-patches. (Sun, 28 May 2017 19:43:02 GMT) Full text and rfc822 format available.

Message #23 received at 27049 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Arun Isaac <arunisaac <at> systemreboot.net>
Cc: 27049 <at> debbugs.gnu.org
Subject: Re: bug#27049: Acknowledgement ([PATCH] gnu: Add mathjax.)
Date: Sun, 28 May 2017 21:41:55 +0200
Arun Isaac <arunisaac <at> systemreboot.net> skribis:

>> +         (let ((install-dir (string-append %output "/share/webapps/mathjax"))
>
> I don't know if this is the correct path to install mathjax to. Do we
> have any conventions/standards for this? Should I just put it in
> /share/mathjax ?

Maybe share/javascript?  Does Node have an opinion on where JS should
live?  What does Debian do?

Thanks,
Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#27049; Package guix-patches. (Mon, 29 May 2017 07:49:01 GMT) Full text and rfc822 format available.

Message #26 received at 27049 <at> debbugs.gnu.org (full text, mbox):

From: Brendan Tildesley <brendan.tildesley <at> openmailbox.org>
Cc: 27049 <at> debbugs.gnu.org
Subject: Re: bug#27049: [PATCH] gnu: Add mathjax.
Date: Mon, 29 May 2017 17:47:54 +1000
Ludovic Courtès 於 2017-05-29 03:41 寫道:
> Hello,
>
> Brendan Tildesley <brendan.tildesley <at> openmailbox.org> skribis:
>
>> Arun Isaac 於 2017-05-24 07:43 寫道:
>> [...]
> Also, Arun: is this package really source code?  Or does it contain
> “minified” code and also bundles all its dependencies (which would not
> be okay)?
>
> Thanks,
> Ludo’.

It contains both. The jax/ directory contains minified code, and the
unpacked/ directory contains the human-readable source. I do not know
what the procedure is for minifying javascript. Do you think we should
delete the jax/ directory and reconstruct it for unpacked/ as apart of
the builder?





Information forwarded to guix-patches <at> gnu.org:
bug#27049; Package guix-patches. (Mon, 29 May 2017 09:35:01 GMT) Full text and rfc822 format available.

Message #29 received at 27049 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Arun Isaac <arunisaac <at> systemreboot.net>
Cc: Brendan Tildesley <brendan.tildesley <at> openmailbox.org>,
 27049 <at> debbugs.gnu.org
Subject: Re: bug#27049: [PATCH] gnu: Add mathjax.
Date: Mon, 29 May 2017 11:34:20 +0200
Arun Isaac <arunisaac <at> systemreboot.net> skribis:

> Ludovic Courtès writes:
>
>> Also, Arun: is this package really source code?  Or does it contain
>> “minified” code and also bundles all its dependencies (which would not
>> be okay)?
>
> Good question! I had assumed it was the full source code without
> checking carefully! I checked just now. The full source code is in the
> "unpacked" directory of the tarball. The code in the top level directory
> of the tarball is minified code. I think we should install only the
> minified code to share/javascript/mathjax/.

Yes, but we should treat minified code as “object code”: we’d remove it
in a snippet and then minify from source.

ISTR that the common minifiers depend on a lot of Node packages, so this
may be a can of worms.  Maybe Jelle or Chris or Dave know more?

> And, like Brendan said, we should separate the fonts into a font-mathjax
> package. And, these fonts should be symlinked into the js-mathjax
> package.

Agreed.

Thanks!

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#27049; Package guix-patches. (Mon, 29 May 2017 11:14:01 GMT) Full text and rfc822 format available.

Message #32 received at 27049 <at> debbugs.gnu.org (full text, mbox):

From: Jelle Licht <jlicht <at> fsfe.org>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 27049 <at> debbugs.gnu.org, Arun Isaac <arunisaac <at> systemreboot.net>
Subject: Re: bug#27049: [PATCH] gnu: Add mathjax.
Date: Mon, 29 May 2017 13:13:23 +0200
[Message part 1 (text/plain, inline)]
2017-05-29 11:34 GMT+02:00 Ludovic Courtès <ludo <at> gnu.org>:

> Arun Isaac <arunisaac <at> systemreboot.net> skribis:
>
> > Ludovic Courtès writes:
> >
> >> Also, Arun: is this package really source code?  Or does it contain
> >> “minified” code and also bundles all its dependencies (which would not
> >> be okay)?
> >
> > Good question! I had assumed it was the full source code without
> > checking carefully! I checked just now. The full source code is in the
> > "unpacked" directory of the tarball. The code in the top level directory
> > of the tarball is minified code. I think we should install only the
> > minified code to share/javascript/mathjax/.
>
> Yes, but we should treat minified code as “object code”: we’d remove it
> in a snippet and then minify from source.
>
> ISTR that the common minifiers depend on a lot of Node packages, so this
> may be a can of worms.  Maybe Jelle or Chris or Dave know more?
>

The minifiers I use for work are usually designed as a plugin in a bigger
node packages, so they suffer from the bootstrap problem lots of node
packages have if you want to build them from source.
Maybe we could look for a smaller, standalone minifier package that we
could use for all minification needs in guix? I always used uglify-js from
before my guix days, so I am not sure how workable it would be to package.



> > And, like Brendan said, we should separate the fonts into a font-mathjax
> > package. And, these fonts should be symlinked into the js-mathjax
> > package.
>
> Agreed.
>
> Thanks!
>
> Ludo’.
>
>
- Jelle
[Message part 2 (text/html, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#27049; Package guix-patches. (Mon, 29 May 2017 12:06:01 GMT) Full text and rfc822 format available.

Message #35 received at 27049 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Jelle Licht <jlicht <at> fsfe.org>
Cc: 27049 <at> debbugs.gnu.org, Arun Isaac <arunisaac <at> systemreboot.net>
Subject: Re: bug#27049: [PATCH] gnu: Add mathjax.
Date: Mon, 29 May 2017 14:05:36 +0200
Jelle Licht <jlicht <at> fsfe.org> skribis:

> 2017-05-29 11:34 GMT+02:00 Ludovic Courtès <ludo <at> gnu.org>:
>
>> Arun Isaac <arunisaac <at> systemreboot.net> skribis:
>>
>> > Ludovic Courtès writes:
>> >
>> >> Also, Arun: is this package really source code?  Or does it contain
>> >> “minified” code and also bundles all its dependencies (which would not
>> >> be okay)?
>> >
>> > Good question! I had assumed it was the full source code without
>> > checking carefully! I checked just now. The full source code is in the
>> > "unpacked" directory of the tarball. The code in the top level directory
>> > of the tarball is minified code. I think we should install only the
>> > minified code to share/javascript/mathjax/.
>>
>> Yes, but we should treat minified code as “object code”: we’d remove it
>> in a snippet and then minify from source.
>>
>> ISTR that the common minifiers depend on a lot of Node packages, so this
>> may be a can of worms.  Maybe Jelle or Chris or Dave know more?
>>
>
> The minifiers I use for work are usually designed as a plugin in a bigger
> node packages, so they suffer from the bootstrap problem lots of node
> packages have if you want to build them from source.
> Maybe we could look for a smaller, standalone minifier package that we
> could use for all minification needs in guix? I always used uglify-js from
> before my guix days, so I am not sure how workable it would be to package.

What smaller, standalone minifier would you suggest?  :-)

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#27049; Package guix-patches. (Mon, 29 May 2017 12:27:02 GMT) Full text and rfc822 format available.

Message #38 received at 27049 <at> debbugs.gnu.org (full text, mbox):

From: Jelle Licht <jlicht <at> fsfe.org>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 27049 <at> debbugs.gnu.org, Arun Isaac <arunisaac <at> systemreboot.net>
Subject: Re: bug#27049: [PATCH] gnu: Add mathjax.
Date: Mon, 29 May 2017 14:26:11 +0200
[Message part 1 (text/plain, inline)]
2017-05-29 14:05 GMT+02:00 Ludovic Courtès <ludo <at> gnu.org>:

> Jelle Licht <jlicht <at> fsfe.org> skribis:
>
> > 2017-05-29 11:34 GMT+02:00 Ludovic Courtès <ludo <at> gnu.org>:
> >
> >> Arun Isaac <arunisaac <at> systemreboot.net> skribis:
> >>
> >> > Ludovic Courtès writes:
> >> >
> >> >> Also, Arun: is this package really source code?  Or does it contain
> >> >> “minified” code and also bundles all its dependencies (which would
> not
> >> >> be okay)?
> >> >
> >> > Good question! I had assumed it was the full source code without
> >> > checking carefully! I checked just now. The full source code is in the
> >> > "unpacked" directory of the tarball. The code in the top level
> directory
> >> > of the tarball is minified code. I think we should install only the
> >> > minified code to share/javascript/mathjax/.
> >>
> >> Yes, but we should treat minified code as “object code”: we’d remove it
> >> in a snippet and then minify from source.
> >>
> >> ISTR that the common minifiers depend on a lot of Node packages, so this
> >> may be a can of worms.  Maybe Jelle or Chris or Dave know more?
> >>
> >
> > The minifiers I use for work are usually designed as a plugin in a bigger
> > node packages, so they suffer from the bootstrap problem lots of node
> > packages have if you want to build them from source.
> > Maybe we could look for a smaller, standalone minifier package that we
> > could use for all minification needs in guix? I always used uglify-js
> from
> > before my guix days, so I am not sure how workable it would be to
> package.
>
> What smaller, standalone minifier would you suggest?  :-)
>

That is an interesting question. A cursory glance at the uglify-js leads me
to believe it could probably be packaged. The standard node-in-guix issues
apply though:
- We do not have a test framework packaged, so running tests to verify that
packages actually work is going to be difficult.
- We end up with a bare-bones package, as some features require problematic
packages (in this case source-maps seems non-trivial to get packaged, due
to a dependency on webpack). The package itself does not have knowledge of
these issues though, so any attempt to use these unsupported features would
lead to a crash.

The second point is less of an issue if this minifier packages is only used
internally as part of a build process.

Another issue with minifiers in general is that is Very Hard to write a
proper minifier. If we choose to not use the minifier as expected by the
package author, we will at some point run into issues that will be very
hard to report and get fixed upstream, as it will only be us experiencing
these issues due to our ... unique .. build procedure.


>
> Ludo’.
>

Maybe some sustainable progress could be made by abusing pars of guile's JS
frontend?
The process could go like this:
JavaScript source -> AST -> minify identifiers, tree shakers etc ->
Serialize AST to minified .js file.

- Jelle
[Message part 2 (text/html, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#27049; Package guix-patches. (Mon, 29 May 2017 16:05:01 GMT) Full text and rfc822 format available.

Message #41 received at 27049 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Jelle Licht <jlicht <at> fsfe.org>
Cc: 27049 <at> debbugs.gnu.org, Arun Isaac <arunisaac <at> systemreboot.net>
Subject: Re: bug#27049: [PATCH] gnu: Add mathjax.
Date: Mon, 29 May 2017 18:04:19 +0200
Jelle Licht <jlicht <at> fsfe.org> skribis:

> That is an interesting question. A cursory glance at the uglify-js leads me
> to believe it could probably be packaged. The standard node-in-guix issues
> apply though:
> - We do not have a test framework packaged, so running tests to verify that
> packages actually work is going to be difficult.
> - We end up with a bare-bones package, as some features require problematic
> packages (in this case source-maps seems non-trivial to get packaged, due
> to a dependency on webpack). The package itself does not have knowledge of
> these issues though, so any attempt to use these unsupported features would
> lead to a crash.
>
> The second point is less of an issue if this minifier packages is only used
> internally as part of a build process.

OK.

> Another issue with minifiers in general is that is Very Hard to write a
> proper minifier. If we choose to not use the minifier as expected by the
> package author, we will at some point run into issues that will be very
> hard to report and get fixed upstream, as it will only be us experiencing
> these issues due to our ... unique .. build procedure.

Sure.  My suggestion would be to use an existing, established minifier,
only one that is relatively simple to package.  It could be one written
in a language other than JS (Ricardo mentioned ‘cl-uglify-js’ on IRC),
or it could be a simplistic minifier written in JS but with very few or
not dependencies, if that exists.

> Maybe some sustainable progress could be made by abusing pars of guile's JS
> frontend?
> The process could go like this:
> JavaScript source -> AST -> minify identifiers, tree shakers etc ->
> Serialize AST to minified .js file.

That would be an interesting exercise, but probably a more risky
approach.  :-)

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#27049; Package guix-patches. (Mon, 29 May 2017 18:49:01 GMT) Full text and rfc822 format available.

Message #44 received at 27049 <at> debbugs.gnu.org (full text, mbox):

From: Arun Isaac <arunisaac <at> systemreboot.net>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 27049 <at> debbugs.gnu.org
Subject: Re: bug#27049: Acknowledgement ([PATCH] gnu: Add mathjax.)
Date: Tue, 30 May 2017 00:17:54 +0530
Ludovic Courtès writes:

> Arun Isaac <arunisaac <at> systemreboot.net> skribis:
>
>>> +         (let ((install-dir (string-append %output "/share/webapps/mathjax"))
>>
>> I don't know if this is the correct path to install mathjax to. Do we
>> have any conventions/standards for this? Should I just put it in
>> /share/mathjax ?
>
> Maybe share/javascript?

I think we should do /share/javascript/mathjax

> Does Node have an opinion on where JS should live?

I have never actually used Node, and don't know much about it. Looking
at
https://stackoverflow.com/questions/5926672/where-does-npm-install-packages
it seems that npm, by default, installs to /usr/local/lib/node and
/usr/local/lib/node_modules

> What does Debian do?

Debian puts it under /usr/share/javascript/mathjax/. Debian has both
minified code and the full "unpacked" source code installed.




Information forwarded to guix-patches <at> gnu.org:
bug#27049; Package guix-patches. (Mon, 29 May 2017 19:20:01 GMT) Full text and rfc822 format available.

Message #47 received at 27049 <at> debbugs.gnu.org (full text, mbox):

From: Arun Isaac <arunisaac <at> systemreboot.net>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: Brendan Tildesley <brendan.tildesley <at> openmailbox.org>,
 27049 <at> debbugs.gnu.org, Jelle Licht <jlicht <at> fsfe.org>
Subject: Re: bug#27049: [PATCH] gnu: Add mathjax.
Date: Tue, 30 May 2017 00:49:33 +0530
> Sure.  My suggestion would be to use an existing, established minifier,
> only one that is relatively simple to package.  It could be one written
> in a language other than JS (Ricardo mentioned ‘cl-uglify-js’ on IRC),
> or it could be a simplistic minifier written in JS but with very few or
> not dependencies, if that exists.

There are several js minifiers written in python. Here's one:

https://github.com/tikitu/jsmin/

I've never used it. I only found it five minutes ago with an internet
search. But, if appearances are anything, it looks relatively well
maintained.




Information forwarded to guix-patches <at> gnu.org:
bug#27049; Package guix-patches. (Tue, 30 May 2017 00:56:02 GMT) Full text and rfc822 format available.

Message #50 received at 27049 <at> debbugs.gnu.org (full text, mbox):

From: Mike Gerwitz <mtg <at> gnu.org>
To: ludo <at> gnu.org (Ludovic Courtès)
Cc: 27049 <at> debbugs.gnu.org, Jelle Licht <jlicht <at> fsfe.org>
Subject: Re: bug#27049: [PATCH] gnu: Add mathjax.
Date: Mon, 29 May 2017 20:55:14 -0400
[Message part 1 (text/plain, inline)]
On Mon, May 29, 2017 at 18:04:19 +0200, Ludovic Courtès wrote:
> Jelle Licht <jlicht <at> fsfe.org> skribis:
>> Another issue with minifiers in general is that is Very Hard to write a
>> proper minifier. If we choose to not use the minifier as expected by the
>> package author, we will at some point run into issues that will be very
>> hard to report and get fixed upstream, as it will only be us experiencing
>> these issues due to our ... unique .. build procedure.
>
> Sure.  My suggestion would be to use an existing, established minifier,
> only one that is relatively simple to package.  It could be one written
> in a language other than JS (Ricardo mentioned ‘cl-uglify-js’ on IRC),
> or it could be a simplistic minifier written in JS but with very few or
> not dependencies, if that exists.

Further, minifiers have various options and some methods are more
aggressive than others.  Last I checked a couple years ago, for example,
Closure Compiler broke GNU ease.js on its more aggressive setting.  The
break was obvious from running my test suite, but some breaks were
subtle and would have caused nightmares in production.  Perhaps things
have since improved.

My point is, though, that Jelle's concerns are shared.  Closure Compiler
is written by Google, and they tend to know what they're doing in this
area. ;)

I'm not saying I'm opposed; it sounds fine to me.  Just be careful!

-- 
Mike Gerwitz
Free Software Hacker+Activist | GNU Maintainer & Volunteer
GPG: D6E9 B930 028A 6C38 F43B  2388 FEF6 3574 5E6F 6D05
https://mikegerwitz.com
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#27049; Package guix-patches. (Fri, 02 Jun 2017 20:34:01 GMT) Full text and rfc822 format available.

Message #53 received at 27049 <at> debbugs.gnu.org (full text, mbox):

From: Arun Isaac <arunisaac <at> systemreboot.net>
To: 27049 <at> debbugs.gnu.org
Cc: Arun Isaac <arunisaac <at> systemreboot.net>
Subject: [PATCH 1/2] gnu: Add font-mathjax.
Date: Sat,  3 Jun 2017 02:03:07 +0530
* gnu/packages/fonts.scm (font-mathjax): New variable.
---
 gnu/packages/fonts.scm | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/gnu/packages/fonts.scm b/gnu/packages/fonts.scm
index 73d76a461..15f70dddd 100644
--- a/gnu/packages/fonts.scm
+++ b/gnu/packages/fonts.scm
@@ -19,6 +19,7 @@
 ;;; Copyright © 2017 Alex Griffin <a <at> ajgrf.com>
 ;;; Copyright © 2017 Clément Lassieur <clement <at> lassieur.org>
 ;;; Copyright © 2017 Brendan Tildesley <brendan.tildesley <at> openmailbox.org>
+;;; Copyright © 2017 Arun Isaac <arunisaac <at> systemreboot.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1227,3 +1228,46 @@ Ensuring readability and clarity at both large and small sizes, these icons
 have been optimized for beautiful display on all common platforms and display
 resolutions.")
    (license license:asl2.0)))
+
+(define-public font-mathjax
+  (package
+    (name "font-mathjax")
+    (version "2.7.1")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append
+             "https://github.com/mathjax/MathJax/archive/"
+             version ".tar.gz"))
+       (file-name (string-append name "-" version ".tar.gz"))
+       (sha256
+        (base32
+         "0sbib5lk0jrvbq6s72ag6ss3wjlz5wnk07ddxij1kp96yg3c1d1b"))))
+    (build-system trivial-build-system)
+    (arguments
+     `(#:modules ((guix build utils))
+       #:builder
+       (begin
+         (use-modules (guix build utils)
+                      (ice-9 match))
+         (setenv "PATH" (string-join (map (match-lambda
+                                            ((_ . input-path)
+                                             (string-append input-path "/bin")))
+                                          %build-inputs)
+                                     ":"))
+         (let ((install-directory (string-append %output "/share/fonts/mathjax")))
+           (mkdir-p install-directory)
+           (zero? (system* "tar" "-C" install-directory "-xvf"
+                           (assoc-ref %build-inputs "source")
+                           "MathJax-2.7.1/fonts" "--strip" "2"))))))
+    (native-inputs
+     `(("gzip" ,gzip)
+       ("tar" ,tar)))
+    (home-page "https://www.mathjax.org/")
+    (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.")
+    (license license:asl2.0)))
-- 
2.12.2





Information forwarded to guix-patches <at> gnu.org:
bug#27049; Package guix-patches. (Fri, 02 Jun 2017 20:34:02 GMT) Full text and rfc822 format available.

Message #56 received at 27049 <at> debbugs.gnu.org (full text, mbox):

From: Arun Isaac <arunisaac <at> systemreboot.net>
To: 27049 <at> debbugs.gnu.org
Cc: Arun Isaac <arunisaac <at> systemreboot.net>
Subject: [PATCH 2/2] gnu: Add js-mathjax.
Date: Sat,  3 Jun 2017 02:03:08 +0530
* gnu/packages/javascript.scm: New file.
* gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
* gnu/packages/javascript.scm (js-mathjax): New variable.
---
 gnu/local.mk                |  1 +
 gnu/packages/javascript.scm | 90 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 91 insertions(+)
 create mode 100644 gnu/packages/javascript.scm

diff --git a/gnu/local.mk b/gnu/local.mk
index e7d5ee2f4..efeb57ab9 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 000000000..de8567dc4
--- /dev/null
+++ b/gnu/packages/javascript.scm
@@ -0,0 +1,90 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2017 Arun Isaac <arunisaac <at> 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
+    (name "js-mathjax")
+    (version "2.7.1")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append
+             "https://github.com/mathjax/MathJax/archive/"
+             version ".tar.gz"))
+       (file-name (string-append name "-" version ".tar.gz"))
+       (sha256
+        (base32
+         "0sbib5lk0jrvbq6s72ag6ss3wjlz5wnk07ddxij1kp96yg3c1d1b"))))
+    (build-system trivial-build-system)
+    (arguments
+     `(#:modules ((guix build utils))
+       #:builder
+       (begin
+         (use-modules (guix build utils)
+                      (ice-9 match)
+                      (ice-9 regex))
+         (setenv "PATH" (string-join (map (match-lambda
+                                            ((_ . input-path)
+                                             (string-append input-path "/bin")))
+                                          %build-inputs)
+                                     ":"))
+         (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 ((install-path (string-append install-directory
+                                                 ;; remove prefix "."
+                                                 (string-drop file 1))))
+                (format #t "~a -> ~a~%" file install-path)
+                (cond
+                 ((string-match "\\.js$" file)
+                  (mkdir-p (dirname install-path))
+                  (system (format #f "uglify-js ~a > ~a" file install-path)))
+                 (else
+                  (install-file file (dirname install-path))))))
+            (find-files "."))))))
+    (native-inputs
+     `(("font-mathjax" ,font-mathjax)
+       ("gzip" ,gzip)
+       ("tar" ,tar)
+       ("uglify-js" ,uglify-js)))
+    (home-page "https://www.mathjax.org/")
+    (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.")
+    (license license:asl2.0)))
-- 
2.12.2





Information forwarded to guix-patches <at> gnu.org:
bug#27049; Package guix-patches. (Fri, 02 Jun 2017 20:39:01 GMT) Full text and rfc822 format available.

Message #59 received at 27049 <at> debbugs.gnu.org (full text, mbox):

From: Arun Isaac <arunisaac <at> systemreboot.net>
To: 27049 <at> debbugs.gnu.org
Cc: Brendan Tildesley <brendan.tildesley <at> openmailbox.org>,
 Ludovic Courtès <ludo <at> gnu.org>
Subject: Re: [PATCH 2/2] gnu: Add js-mathjax.
Date: Sat, 03 Jun 2017 02:07:58 +0530
These are WIP patches. Please provide feedback.

> +         (setenv "PATH" (string-join (map (match-lambda
> +                                            ((_ . input-path)
> +                                             (string-append input-path "/bin")))
> +                                          %build-inputs)
> +                                     ":"))

It would be nice if this was handled by the trivial-build-system
itself. Almost all trivial-build-system packages I can think of need
some variant of this.

> +                (cond
> +                 ((string-match "\\.js$" file)
> +                  (mkdir-p (dirname install-path))
> +                  (system (format #f "uglify-js ~a > ~a" file install-path)))

I have to use `system' instead of `system*' here, because I need to make
use of ">" to redirect output to a file.

While minifying some files, an ascii decoding error is reported. I'm yet
to sort that out.




Information forwarded to guix-patches <at> gnu.org:
bug#27049; Package guix-patches. (Sat, 03 Jun 2017 13:31:01 GMT) Full text and rfc822 format available.

Message #62 received at 27049 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Arun Isaac <arunisaac <at> systemreboot.net>
Cc: Brendan Tildesley <brendan.tildesley <at> openmailbox.org>,
 27049 <at> debbugs.gnu.org
Subject: Re: [PATCH 2/2] gnu: Add js-mathjax.
Date: Sat, 03 Jun 2017 15:30:22 +0200
Hi,

Arun Isaac <arunisaac <at> systemreboot.net> skribis:

> These are WIP patches. Please provide feedback.
>
>> +         (setenv "PATH" (string-join (map (match-lambda
>> +                                            ((_ . input-path)
>> +                                             (string-append input-path "/bin")))
>> +                                          %build-inputs)
>> +                                     ":"))
>
> It would be nice if this was handled by the trivial-build-system
> itself. Almost all trivial-build-system packages I can think of need
> some variant of this.

You could use ‘set-path-environment-variable’ from (guix build utils) to
slightly simplify this.

>> +                (cond
>> +                 ((string-match "\\.js$" file)
>> +                  (mkdir-p (dirname install-path))
>> +                  (system (format #f "uglify-js ~a > ~a" file install-path)))
>
> I have to use `system' instead of `system*' here, because I need to make
> use of ">" to redirect output to a file.

That’s OK, though you could also use ‘open-input-pipe’ from (ice-9
popen):

  (let ((minified (open-pipe* OPEN_READ "uglify-js" file)))
    (call-with-output-file installed
      (lambda (port)
        (dump-port minified port))))

> While minifying some files, an ascii decoding error is reported. I'm yet
> to sort that out.

You might need to run that in a UTF-8 locale, which requires adding
glibc-utf8-locales as an input etc.

HTH!

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#27049; Package guix-patches. (Sat, 03 Jun 2017 13:52:03 GMT) Full text and rfc822 format available.

Message #65 received at 27049 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Arun Isaac <arunisaac <at> systemreboot.net>
Cc: 27049 <at> debbugs.gnu.org
Subject: Re: bug#27049: [PATCH 1/2] gnu: Add font-mathjax.
Date: Sat, 03 Jun 2017 15:51:44 +0200
Hi Arun,

Arun Isaac <arunisaac <at> systemreboot.net> skribis:

> * gnu/packages/fonts.scm (font-mathjax): New variable.

[...]

> +(define-public font-mathjax
> +  (package
> +    (name "font-mathjax")
> +    (version "2.7.1")
> +    (source
> +     (origin
> +       (method url-fetch)
> +       (uri (string-append
> +             "https://github.com/mathjax/MathJax/archive/"
> +             version ".tar.gz"))
> +       (file-name (string-append name "-" version ".tar.gz"))
> +       (sha256
> +        (base32
> +         "0sbib5lk0jrvbq6s72ag6ss3wjlz5wnk07ddxij1kp96yg3c1d1b"))))

Should it be:

  (source (package-source mathjax))

to make sure the two packages are kept in sync?

> +    (home-page "https://www.mathjax.org/")
> +    (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.")
> +    (license license:asl2.0)))

I think the synopsis/description should be updated to mention that this
package simply provides the font used by MathJax, no?

Otherwise LGTM, thanks!

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#27049; Package guix-patches. (Sat, 03 Jun 2017 13:54:02 GMT) Full text and rfc822 format available.

Message #68 received at 27049 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Arun Isaac <arunisaac <at> systemreboot.net>
Cc: 27049 <at> debbugs.gnu.org
Subject: Re: bug#27049: [PATCH 2/2] gnu: Add js-mathjax.
Date: Sat, 03 Jun 2017 15:53:42 +0200
Arun Isaac <arunisaac <at> systemreboot.net> skribis:

> * gnu/packages/javascript.scm: New file.
> * gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
> * gnu/packages/javascript.scm (js-mathjax): New variable.

[...]

> +           (for-each
> +            (lambda (file)
> +              (let ((install-path (string-append install-directory
> +                                                 ;; remove prefix "."
> +                                                 (string-drop file 1))))
> +                (format #t "~a -> ~a~%" file install-path)
> +                (cond
> +                 ((string-match "\\.js$" file)
> +                  (mkdir-p (dirname install-path))
> +                  (system (format #f "uglify-js ~a > ~a" file install-path)))
> +                 (else
> +                  (install-file file (dirname install-path))))))
> +            (find-files "."))))))

Nitpick: in GNU “path” is used to denote search paths; we use “file
names” for files.  So s/install-path/installed-file/ or something like
that.

(I already wrote about ‘system’ in another message.)

Otherwise LGTM, thanks!

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#27049; Package guix-patches. (Sun, 04 Jun 2017 18:59:02 GMT) Full text and rfc822 format available.

Message #71 received at 27049 <at> debbugs.gnu.org (full text, mbox):

From: Arun Isaac <arunisaac <at> systemreboot.net>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 27049 <at> debbugs.gnu.org
Subject: Re: bug#27049: [PATCH 2/2] gnu: Add js-mathjax.
Date: Mon, 05 Jun 2017 00:27:39 +0530
[Message part 1 (text/plain, inline)]
I've made all suggested changes. Please find attached a new patchset.

[mathjax-series.patch (text/x-patch, inline)]
From 7d843968b04960c93b7238cb4557064d03ef4f84 Mon Sep 17 00:00:00 2001
From: Arun Isaac <arunisaac <at> systemreboot.net>
Date: Sat, 3 Jun 2017 01:42:15 +0530
Subject: [PATCH 1/2] gnu: Add font-mathjax.

* gnu/packages/fonts.scm (font-mathjax): New variable.
---
 gnu/packages/fonts.scm | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/gnu/packages/fonts.scm b/gnu/packages/fonts.scm
index 73d76a461..59e60dc29 100644
--- a/gnu/packages/fonts.scm
+++ b/gnu/packages/fonts.scm
@@ -19,6 +19,7 @@
 ;;; Copyright © 2017 Alex Griffin <a <at> ajgrf.com>
 ;;; Copyright © 2017 Clément Lassieur <clement <at> lassieur.org>
 ;;; Copyright © 2017 Brendan Tildesley <brendan.tildesley <at> openmailbox.org>
+;;; Copyright © 2017 Arun Isaac <arunisaac <at> systemreboot.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1227,3 +1228,42 @@ Ensuring readability and clarity at both large and small sizes, these icons
 have been optimized for beautiful display on all common platforms and display
 resolutions.")
    (license license:asl2.0)))
+
+(define-public font-mathjax
+  (package
+    (name "font-mathjax")
+    (version "2.7.1")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append
+             "https://github.com/mathjax/MathJax/archive/"
+             version ".tar.gz"))
+       (file-name (string-append name "-" version ".tar.gz"))
+       (sha256
+        (base32
+         "0sbib5lk0jrvbq6s72ag6ss3wjlz5wnk07ddxij1kp96yg3c1d1b"))))
+    (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))
+         (let ((install-directory (string-append %output "/share/fonts/mathjax")))
+           (mkdir-p install-directory)
+           (zero? (system* "tar" "-C" install-directory "-xvf"
+                           (assoc-ref %build-inputs "source")
+                           "MathJax-2.7.1/fonts" "--strip" "2"))))))
+    (native-inputs
+     `(("gzip" ,gzip)
+       ("tar" ,tar)))
+    (home-page "https://www.mathjax.org/")
+    (synopsis "Fonts for MathJax")
+    (description "This package contains the fonts required for MathJax.")
+    (license license:asl2.0)))
-- 
2.12.2

From 01850ce06c0a55677266bae865a3c16e4f710094 Mon Sep 17 00:00:00 2001
From: Arun Isaac <arunisaac <at> systemreboot.net>
Date: Sat, 3 Jun 2017 01:57:51 +0530
Subject: [PATCH 2/2] 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.
---
 gnu/local.mk                |  1 +
 gnu/packages/javascript.scm | 85 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 86 insertions(+)
 create mode 100644 gnu/packages/javascript.scm

diff --git a/gnu/local.mk b/gnu/local.mk
index 0449e8adc..0ab215971 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 000000000..6746ad1d2
--- /dev/null
+++ b/gnu/packages/javascript.scm
@@ -0,0 +1,85 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2017 Arun Isaac <arunisaac <at> 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.")))
-- 
2.12.2


Information forwarded to guix-patches <at> gnu.org:
bug#27049; Package guix-patches. (Mon, 05 Jun 2017 10:11:02 GMT) Full text and rfc822 format available.

Message #74 received at 27049 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Arun Isaac <arunisaac <at> systemreboot.net>
Cc: 27049 <at> debbugs.gnu.org
Subject: Re: bug#27049: [PATCH 2/2] gnu: Add js-mathjax.
Date: Mon, 05 Jun 2017 12:10:12 +0200
Arun Isaac <arunisaac <at> systemreboot.net> skribis:

> I've made all suggested changes. Please find attached a new patchset.
>
> From 7d843968b04960c93b7238cb4557064d03ef4f84 Mon Sep 17 00:00:00 2001
> From: Arun Isaac <arunisaac <at> systemreboot.net>
> Date: Sat, 3 Jun 2017 01:42:15 +0530
> Subject: [PATCH 1/2] gnu: Add font-mathjax.
>
> * gnu/packages/fonts.scm (font-mathjax): New variable.

[...]

> From 01850ce06c0a55677266bae865a3c16e4f710094 Mon Sep 17 00:00:00 2001
> From: Arun Isaac <arunisaac <at> systemreboot.net>
> Date: Sat, 3 Jun 2017 01:57:51 +0530
> Subject: [PATCH 2/2] 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.

Both LGTM, thank you!

Ludo’.




Reply sent to Arun Isaac <arunisaac <at> systemreboot.net>:
You have taken responsibility. (Mon, 05 Jun 2017 13:49:02 GMT) Full text and rfc822 format available.

Notification sent to Arun Isaac <arunisaac <at> systemreboot.net>:
bug acknowledged by developer. (Mon, 05 Jun 2017 13:49:02 GMT) Full text and rfc822 format available.

Message #79 received at 27049-done <at> debbugs.gnu.org (full text, mbox):

From: Arun Isaac <arunisaac <at> systemreboot.net>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 27049-done <at> debbugs.gnu.org
Subject: Re: bug#27049: [PATCH 2/2] gnu: Add js-mathjax.
Date: Mon, 05 Jun 2017 19:18:04 +0530
Pushed!




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 04 Jul 2017 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 6 years and 292 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.