summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Kummerlaender2018-09-23 21:18:29 +0200
committerAdrian Kummerlaender2018-09-23 21:18:29 +0200
commitea7a07c1803b84529301b1eb568a3066dfdefc9f (patch)
tree1ad291e3f2b10004525a2c9a26fd36989b5007c6
parent43bc484b4e3dc47512872e62779d7fe98fac93a1 (diff)
downloadpkgs-ea7a07c1803b84529301b1eb568a3066dfdefc9f.tar
pkgs-ea7a07c1803b84529301b1eb568a3066dfdefc9f.tar.gz
pkgs-ea7a07c1803b84529301b1eb568a3066dfdefc9f.tar.bz2
pkgs-ea7a07c1803b84529301b1eb568a3066dfdefc9f.tar.xz
pkgs-ea7a07c1803b84529301b1eb568a3066dfdefc9f.zip
Add KaTeX derivation
-rw-r--r--default.nix2
-rw-r--r--pkgs/KaTeX/default.nix49
2 files changed, 51 insertions, 0 deletions
diff --git a/default.nix b/default.nix
index a04c69d..ffc0ddd 100644
--- a/default.nix
+++ b/default.nix
@@ -11,6 +11,8 @@ let
oomox-gtk-theme = callPackage ./pkgs/oomox-gtk-theme { };
oomox-archdroid-icon-theme = callPackage ./pkgs/oomox-archdroid-icon-theme { };
+ KaTeX = callPackage ./pkgs/KaTeX { };
+
InputXSLT = callPackage ./pkgs/xslt/InputXSLT { };
StaticXSLT = callPackage ./pkgs/xslt/StaticXSLT { };
BuildXSLT = callPackage ./pkgs/xslt/BuildXSLT { };
diff --git a/pkgs/KaTeX/default.nix b/pkgs/KaTeX/default.nix
new file mode 100644
index 0000000..37fe63a
--- /dev/null
+++ b/pkgs/KaTeX/default.nix
@@ -0,0 +1,49 @@
+{ stdenv, pkgs, ... }:
+
+let
+ katex-src = stdenv.mkDerivation rec {
+ name = "katex-src";
+
+ src = pkgs.fetchzip {
+ url = "https://github.com/Khan/KaTeX/releases/download/v0.10.0-alpha/katex.zip";
+ sha256 = "002dzyf3wcyjxv4m6vv0v99gf82a9k7rxsnlvf93h9fhcda2vj7l";
+ };
+
+ buildInputs = [ pkgs.nodejs ];
+
+ installPhase = ''
+ mkdir -p $out/share/katex
+ cp katex.min.js $out/share/katex/
+ '';
+
+ meta = {
+ description = "KaTeX";
+ homepage = https://github.com/Khan/KaTeX;
+ license = stdenv.lib.licenses.mit;
+ platforms = stdenv.lib.platforms.all;
+ };
+ };
+in pkgs.writeTextFile {
+ name = "katex-wrapper";
+ executable = true;
+ destination = "/bin/katex";
+
+ text = ''
+ #!${pkgs.nodejs}/bin/node
+
+ var katex = require("${katex-src}/share/katex/katex.min.js");
+ var input = "";
+
+ var args = process.argv.slice(2);
+
+ process.stdin.on("data", function(chunk) {
+ input += chunk.toString();
+ });
+
+ process.stdin.on("end", function() {
+ var options = { displayMode: args.indexOf("--display-mode") !== -1 };
+ var output = katex.renderToString(input, options);
+ console.log(output);
+ });
+ '';
+}