Use duktape to run KaTeX from ruby with Node

Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
This commit is contained in:
Danila Fedorin 2024-05-24 04:23:25 +00:00
parent fda466a8cf
commit 2a86640401
5 changed files with 40 additions and 122 deletions

View File

@ -46,5 +46,5 @@ cp -r public/$publicPath/* $out/
# Render math in HTML and XML files. # Render math in HTML and XML files.
htmlfiles=$(find $out/ -regex "$out/.*\.html") htmlfiles=$(find $out/ -regex "$out/.*\.html")
echo $htmlfiles | xargs katex-html echo $htmlfiles | xargs ${gems}/bin/bundle exec ${ruby}/bin/ruby ./convert.rb --katex-js-file static/katex/katex.min.js
echo $htmlfiles | xargs ${gems}/bin/bundle exec ${ruby}/bin/ruby ./agda.rb echo $htmlfiles | xargs ${gems}/bin/bundle exec ${ruby}/bin/ruby ./agda.rb

View File

@ -2,8 +2,8 @@
"nodes": { "nodes": {
"bergamot-elm": { "bergamot-elm": {
"inputs": { "inputs": {
"flake-utils": "flake-utils_5", "flake-utils": "flake-utils_3",
"nixpkgs": "nixpkgs_5" "nixpkgs": "nixpkgs_3"
}, },
"locked": { "locked": {
"lastModified": 1703837234, "lastModified": 1703837234,
@ -23,11 +23,11 @@
"blog-source": { "blog-source": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1716451027, "lastModified": 1716524089,
"narHash": "sha256-qZ95OGE4QfFDZ5PsRE9u6lri/yS3MGTI9dUkevWoYaI=", "narHash": "sha256-bqYW4a8Cn3AbbxLGDSUs+qOVMTXQ0gFrT7mPDThh2+I=",
"ref": "refs/heads/master", "ref": "refs/heads/master",
"rev": "4d23b456335804e64e165a061d6f3b8d36b9e3ef", "rev": "06ee998d5411cbc4b1b1188711ba582e5fcc6c33",
"revCount": 776, "revCount": 778,
"submodules": true, "submodules": true,
"type": "git", "type": "git",
"url": "https://dev.danilafe.com/Web-Projects/blog-static.git" "url": "https://dev.danilafe.com/Web-Projects/blog-static.git"
@ -54,36 +54,6 @@
} }
}, },
"flake-utils_2": { "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"
}
},
"flake-utils_4": {
"locked": { "locked": {
"lastModified": 1676283394, "lastModified": 1676283394,
"narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=", "narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=",
@ -98,7 +68,7 @@
"type": "github" "type": "github"
} }
}, },
"flake-utils_5": { "flake-utils_3": {
"inputs": { "inputs": {
"systems": "systems" "systems": "systems"
}, },
@ -116,7 +86,7 @@
"type": "github" "type": "github"
} }
}, },
"flake-utils_6": { "flake-utils_4": {
"inputs": { "inputs": {
"systems": "systems_2" "systems": "systems_2"
}, },
@ -134,76 +104,7 @@
"type": "github" "type": "github"
} }
}, },
"katex-html": {
"inputs": {
"flake-utils": "flake-utils_2",
"katex-server": "katex-server",
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1702750878,
"narHash": "sha256-8glJbHNyyYRAWrtJPYqLhNkKAtX2j4jwsX55Tr18MSY=",
"ref": "refs/heads/master",
"rev": "9ddfb114c77b7605b1a0705c7dcd35940b3bd7fb",
"revCount": 15,
"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": 1666145384,
"narHash": "sha256-kpHv3EawXzyR1mRX4joIqqZDYz//xyUMtGMsmJk3YuE=",
"ref": "master",
"rev": "cce6cf6a9458537ff1cb08dd8dad4f8460060f76",
"revCount": 7,
"type": "git",
"url": "https://dev.danilafe.com/Nix-Configs/katex-server"
},
"original": {
"type": "git",
"url": "https://dev.danilafe.com/Nix-Configs/katex-server"
}
},
"nixpkgs": { "nixpkgs": {
"locked": {
"lastModified": 1648444094,
"narHash": "sha256-2liapKh7WXPHELuzLvYK+464g4w9tr9DbNxGuz8XZ98=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "87c74b8120980461a9d4ce8f341551ce0fb50728",
"type": "github"
},
"original": {
"owner": "nixos",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1648444094,
"narHash": "sha256-2liapKh7WXPHELuzLvYK+464g4w9tr9DbNxGuz8XZ98=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "87c74b8120980461a9d4ce8f341551ce0fb50728",
"type": "github"
},
"original": {
"owner": "nixos",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_3": {
"locked": { "locked": {
"lastModified": 1715534503, "lastModified": 1715534503,
"narHash": "sha256-5ZSVkFadZbFP1THataCaSf0JH2cAH3S29hU9rrxTEqk=", "narHash": "sha256-5ZSVkFadZbFP1THataCaSf0JH2cAH3S29hU9rrxTEqk=",
@ -219,7 +120,7 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs_4": { "nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1676718858, "lastModified": 1676718858,
"narHash": "sha256-giQecvcifVLNHCC9lMfTGP09tNxXhOMw+d/aql7MhRw=", "narHash": "sha256-giQecvcifVLNHCC9lMfTGP09tNxXhOMw+d/aql7MhRw=",
@ -235,7 +136,7 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs_5": { "nixpkgs_3": {
"locked": { "locked": {
"lastModified": 1701068326, "lastModified": 1701068326,
"narHash": "sha256-vmMceA+q6hG1yrjb+MP8T0YFDQIrW3bl45e7z24IEts=", "narHash": "sha256-vmMceA+q6hG1yrjb+MP8T0YFDQIrW3bl45e7z24IEts=",
@ -251,7 +152,7 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs_6": { "nixpkgs_4": {
"locked": { "locked": {
"lastModified": 1701319520, "lastModified": 1701319520,
"narHash": "sha256-xVghb4ELbEtJUdEmB4PR+sq/aoNP0VEcM6GczDh+Zss=", "narHash": "sha256-xVghb4ELbEtJUdEmB4PR+sq/aoNP0VEcM6GczDh+Zss=",
@ -268,8 +169,8 @@
}, },
"resume": { "resume": {
"inputs": { "inputs": {
"flake-utils": "flake-utils_4", "flake-utils": "flake-utils_2",
"nixpkgs": "nixpkgs_4" "nixpkgs": "nixpkgs_2"
}, },
"locked": { "locked": {
"lastModified": 1691357458, "lastModified": 1691357458,
@ -289,8 +190,7 @@
"inputs": { "inputs": {
"blog-source": "blog-source", "blog-source": "blog-source",
"flake-utils": "flake-utils", "flake-utils": "flake-utils",
"katex-html": "katex-html", "nixpkgs": "nixpkgs",
"nixpkgs": "nixpkgs_3",
"resume": "resume", "resume": "resume",
"web-files": "web-files" "web-files": "web-files"
} }
@ -328,8 +228,8 @@
"web-files": { "web-files": {
"inputs": { "inputs": {
"bergamot-elm": "bergamot-elm", "bergamot-elm": "bergamot-elm",
"flake-utils": "flake-utils_6", "flake-utils": "flake-utils_4",
"nixpkgs": "nixpkgs_6" "nixpkgs": "nixpkgs_4"
}, },
"locked": { "locked": {
"lastModified": 1703994569, "lastModified": 1703994569,

View File

@ -2,7 +2,6 @@
inputs = { inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils"; flake-utils.url = "github:numtide/flake-utils";
katex-html.url = "git+https://dev.danilafe.com/Nix-Configs/katex-html";
resume.url = "git+https://dev.danilafe.com/DanilaFe/resume"; resume.url = "git+https://dev.danilafe.com/DanilaFe/resume";
blog-source = { blog-source = {
flake = false; flake = false;
@ -13,13 +12,12 @@
web-files.url = "git+https://dev.danilafe.com/Nix-Configs/web-files.git"; web-files.url = "git+https://dev.danilafe.com/Nix-Configs/web-files.git";
}; };
outputs = { self, blog-source, nixpkgs, flake-utils, katex-html, resume, web-files }: outputs = { self, blog-source, nixpkgs, flake-utils, resume, web-files }:
flake-utils.lib.eachDefaultSystem (system: flake-utils.lib.eachDefaultSystem (system:
let let
lib = import ./lib.nix { lib = import ./lib.nix {
inherit blog-source; inherit blog-source;
pkgs = import nixpkgs { inherit system; }; pkgs = import nixpkgs { inherit system; };
katex-html = katex-html.defaultPackage.${system};
resume = resume.defaultPackage.${system}; resume = resume.defaultPackage.${system};
web-files = web-files.defaultPackage.${system}; web-files = web-files.defaultPackage.${system};
}; };

View File

@ -1,4 +1,24 @@
{ {
duktape = {
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "1nrhvxbhflf2lrd8v4rphsf0lwg0lvfws2i0cpq8s0xxgh4lviia";
type = "gem";
};
version = "2.7.0.0";
};
execjs = {
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "1yywajqlpjhrj1m43s3lfg3i4lkb6pxwccmwps7qw37ndmphdzg8";
type = "gem";
};
version = "2.9.1";
};
mini_portile2 = { mini_portile2 = {
groups = ["default"]; groups = ["default"];
platforms = []; platforms = [];

View File

@ -1,4 +1,4 @@
{ pkgs, blog-source, web-files, katex-html, resume }: { pkgs, blog-source, web-files, resume }:
with pkgs; with pkgs;
with lib; with lib;
@ -27,7 +27,7 @@ let
builder = ./build/builder.sh; builder = ./build/builder.sh;
webFiles = web-files; webFiles = web-files;
buildInputs = [ buildInputs = [
hugo ruby stork katex-html (agda.withPackages [ agdaPackages.standard-library ]) hugo ruby stork (agda.withPackages [ agdaPackages.standard-library ])
]; ];
}; };
in in