Extract KaTeX handling into a program

This commit is contained in:
Danila Fedorin 2022-03-27 18:47:07 -07:00
parent 17e18872bf
commit ac1eec35ec
4 changed files with 112 additions and 9 deletions

View File

@ -15,6 +15,4 @@ mkdir $out
cp -r public/$publicPath/* $out/
# Render math in HTML and XML files.
node $server &
sleep 1
find $out/ -regex "$out/.*\.html" | xargs ruby $converter
find $out/ -regex "$out/.*\.html" | xargs katex-html

View File

@ -52,7 +52,106 @@
"type": "github"
}
},
"flake-utils_2": {
"locked": {
"lastModified": 1648297722,
"narHash": "sha256-W+qlPsiZd8F3XkzXOzAoR+mpFqzm3ekQkJNa+PIh1BQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "0f8662f1319ad6abf89b3380dd2722369fc51ade",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_3": {
"locked": {
"lastModified": 1648297722,
"narHash": "sha256-W+qlPsiZd8F3XkzXOzAoR+mpFqzm3ekQkJNa+PIh1BQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "0f8662f1319ad6abf89b3380dd2722369fc51ade",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"katex-html": {
"inputs": {
"flake-utils": "flake-utils_2",
"katex-server": "katex-server",
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1648430978,
"narHash": "sha256-12Bj/RX6rb5ooHHeqIBLa2kizGW9syFyUOQVDzVzGzI=",
"ref": "master",
"rev": "fc26bcf07b5d22cbd4f378130a8fd6d8b0ede9ce",
"revCount": 6,
"type": "git",
"url": "https://dev.danilafe.com/Nix-Configs/katex-html"
},
"original": {
"type": "git",
"url": "https://dev.danilafe.com/Nix-Configs/katex-html"
}
},
"katex-server": {
"inputs": {
"flake-utils": "flake-utils_3",
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1648429554,
"narHash": "sha256-jNRd9gzrOIYlvuVr/Je2Uh6/FXRoGwAIjgVHhf2NOoE=",
"ref": "master",
"rev": "a277542d9b7eb23806b123aed41a0bd441ff669b",
"revCount": 4,
"type": "git",
"url": "https://dev.danilafe.com/Nix-Configs/katex-server"
},
"original": {
"type": "git",
"url": "https://dev.danilafe.com/Nix-Configs/katex-server"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1648425779,
"narHash": "sha256-0tcpEiiq3f3Hh77ax7QFuF15AnPaBIdDSbvrCUeyb9k=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "1edfe6d91bd8348cfccacd72e82d1d06ad470117",
"type": "github"
},
"original": {
"owner": "nixos",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1648425779,
"narHash": "sha256-0tcpEiiq3f3Hh77ax7QFuF15AnPaBIdDSbvrCUeyb9k=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "1edfe6d91bd8348cfccacd72e82d1d06ad470117",
"type": "github"
},
"original": {
"owner": "nixos",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_3": {
"locked": {
"lastModified": 1634881110,
"narHash": "sha256-glFqhVeqPuT99vfKrOH7lmJDrgwP99KJJSFpgpyvbko=",
@ -72,7 +171,8 @@
"blog-source": "blog-source",
"blog-source-localized": "blog-source-localized",
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
"katex-html": "katex-html",
"nixpkgs": "nixpkgs_3"
}
}
},

View File

@ -2,6 +2,7 @@
inputs = {
nixpkgs.url = "github:nixos/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
katex-html.url = "git+https://dev.danilafe.com/Nix-Configs/katex-html";
blog-source = {
flake = false;
url = "https://dev.danilafe.com/Web-Projects/blog-static.git";
@ -17,12 +18,18 @@
};
};
outputs = { self, blog-source, blog-source-localized, nixpkgs, flake-utils }:
outputs = { self, blog-source, blog-source-localized, nixpkgs, flake-utils, katex-html }:
{
buildersFor = system: import ./lib.nix {
inherit blog-source blog-source-localized;
pkgs = import nixpkgs { inherit system; };
katex-html = katex-html.defaultPackage.${system};
};
nixosModule = (import ./module.nix);
packages.x86_64-linux.blog-debug = (import ./lib.nix {
inherit blog-source blog-source-localized;
pkgs = import nixpkgs { system = "x86_64-linux"; };
katex-html = katex-html.defaultPackage."x86_64-linux";
}).english { host = "danilafe.com"; };
};
}

View File

@ -1,4 +1,4 @@
{ blog-source, blog-source-localized, pkgs }:
{ blog-source, blog-source-localized, pkgs, katex-html }:
with pkgs;
@ -16,10 +16,8 @@ let
publicPath = settings.path;
extraFlags = if settings.drafts then " -D " else "";
builder = ./build/builder.sh;
converter = ./build/convert.rb;
server = ./build/katexserver.js;
buildInputs = [
hugo nodejs
hugo nodejs katex-html
requiredPackages."katex-0.11.1"
requiredPackages.express
requiredPackages.body-parser