summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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);
+ });
+ '';
+}