Fix rendering and roll back katex to a version with better fonts.

This commit is contained in:
Danila Fedorin 2020-12-15 04:48:03 +00:00
parent ff3297d5ac
commit 31c0537d43
6 changed files with 9 additions and 11 deletions

View File

@ -16,6 +16,5 @@ cp -r public/$publicPath/* $out/
# Render math in HTML and XML files. # Render math in HTML and XML files.
node $server & node $server &
SERVER_ID=$! sleep 1
find $out/ -regex "$out/.*\.html" | xargs ruby $converter find $out/ -regex "$out/.*\.html" | xargs ruby $converter
kill $SERVER_ID

View File

@ -6,7 +6,7 @@ require "json"
def render_cached(cache, display, string, render_comment = nil) def render_cached(cache, display, string, render_comment = nil)
cache.fetch(string) do |new| cache.fetch(string) do |new|
puts " Rendering #{render_comment || new}" puts " Rendering #{render_comment || new}"
res = Net::HTTP.post URI("http://localhost:3000/render"), res = Net::HTTP.post URI("http://localhost:8000/render"),
{ :equations => [ { :str => string, :display => display } ] }.to_json, { :equations => [ { :str => string, :display => display } ] }.to_json,
"Content-Type" => "application/json" "Content-Type" => "application/json"
cache[string] = JSON.parse(res.body)[0] cache[string] = JSON.parse(res.body)[0]

View File

@ -24,7 +24,7 @@ let
server = ./katexserver.js; server = ./katexserver.js;
buildInputs = [ buildInputs = [
hugo nodejs hugo nodejs
requiredPackages.katex requiredPackages.express requiredPackages.body-parser requiredPackages."katex-0.11.1" requiredPackages.express requiredPackages.body-parser
(ruby.withPackages (ps: [ ps.nokogiri ])) (ruby.withPackages (ps: [ ps.nokogiri ]))
]; ];
}; };

View File

@ -5,8 +5,7 @@ const bodyParser = require('body-parser');
app = express(); app = express();
app.use(bodyParser.json()); app.use(bodyParser.json());
app.post('/render', (req, res) => { app.post('/render', (req, res) => {
console.log(req.body)
res.send(req.body.equations.map(eq => res.send(req.body.equations.map(eq =>
katex.renderToString(eq.str, { throwOnError: false, displayMode: eq.display }))); katex.renderToString(eq.str, { throwOnError: false, displayMode: eq.display })));
}); });
app.listen(3000); app.listen(8000);

View File

@ -457,13 +457,13 @@ let
}; };
in in
{ {
katex = nodeEnv.buildNodePackage { "katex-0.11.1" = nodeEnv.buildNodePackage {
name = "katex"; name = "katex";
packageName = "katex"; packageName = "katex";
version = "0.12.0"; version = "0.11.1";
src = fetchurl { src = fetchurl {
url = "https://registry.npmjs.org/katex/-/katex-0.12.0.tgz"; url = "https://registry.npmjs.org/katex/-/katex-0.11.1.tgz";
sha512 = "y+8btoc/CK70XqcHqjxiGWBOeIL8upbS0peTPXTvgrh21n1RiWWcIpSWM+4uXq+IAgNh9YYQWdc7LVDPDAEEAg=="; sha512 = "5oANDICCTX0NqYIyAiFCCwjQ7ERu3DQG2JFHLbYOf+fXaMoH8eg/zOq5WSYJsKMi/QebW+Eh3gSM+oss1H/bww==";
}; };
dependencies = [ dependencies = [
sources."commander-2.20.3" sources."commander-2.20.3"

View File

@ -1,3 +1,3 @@
[ [
"katex", "express", "body-parser" {"katex": "0.11.1"}, "express", "body-parser"
] ]