Compare commits

..

No commits in common. "master" and "fc26bcf07b5d22cbd4f378130a8fd6d8b0ede9ce" have entirely different histories.

2 changed files with 11 additions and 13 deletions

View File

@ -2,10 +2,8 @@ require "open3"
require "nokogiri" require "nokogiri"
require "net/http" require "net/http"
require "json" require "json"
require "cgi"
def render_cached(cache, display, string, render_comment = nil) def render_cached(cache, display, string, render_comment = nil)
string = CGI.unescapeHTML string
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:8000/render"), res = Net::HTTP.post URI("http://localhost:8000/render"),
@ -31,7 +29,7 @@ inline_cache, display_cache = {}, {}
files.each do |file| files.each do |file|
puts "Rendering file: #{file}" puts "Rendering file: #{file}"
document = Nokogiri::HTML.parse(File.open(file)) document = Nokogiri::HTML.parse(File.open(file))
document.search('//*[not(ancestor-or-self::code or ancestor-or-self::script)]/text()').each do |t| document.search('//*[not(ancestor-or-self::code)]/text()').each do |t|
t.replace(perform_katex_sub(inline_cache, display_cache, t.content)) t.replace(perform_katex_sub(inline_cache, display_cache, t.content))
end end
File.write(file, document.to_html(encoding: 'UTF-8')) File.write(file, document.to_html(encoding: 'UTF-8'))

20
flake.lock generated
View File

@ -36,11 +36,11 @@
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
}, },
"locked": { "locked": {
"lastModified": 1666145384, "lastModified": 1648429554,
"narHash": "sha256-kpHv3EawXzyR1mRX4joIqqZDYz//xyUMtGMsmJk3YuE=", "narHash": "sha256-jNRd9gzrOIYlvuVr/Je2Uh6/FXRoGwAIjgVHhf2NOoE=",
"ref": "master", "ref": "master",
"rev": "cce6cf6a9458537ff1cb08dd8dad4f8460060f76", "rev": "a277542d9b7eb23806b123aed41a0bd441ff669b",
"revCount": 7, "revCount": 4,
"type": "git", "type": "git",
"url": "https://dev.danilafe.com/Nix-Configs/katex-server" "url": "https://dev.danilafe.com/Nix-Configs/katex-server"
}, },
@ -51,11 +51,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1648444094, "lastModified": 1648425779,
"narHash": "sha256-2liapKh7WXPHELuzLvYK+464g4w9tr9DbNxGuz8XZ98=", "narHash": "sha256-0tcpEiiq3f3Hh77ax7QFuF15AnPaBIdDSbvrCUeyb9k=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "87c74b8120980461a9d4ce8f341551ce0fb50728", "rev": "1edfe6d91bd8348cfccacd72e82d1d06ad470117",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -66,11 +66,11 @@
}, },
"nixpkgs_2": { "nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1648444094, "lastModified": 1648425779,
"narHash": "sha256-2liapKh7WXPHELuzLvYK+464g4w9tr9DbNxGuz8XZ98=", "narHash": "sha256-0tcpEiiq3f3Hh77ax7QFuF15AnPaBIdDSbvrCUeyb9k=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "87c74b8120980461a9d4ce8f341551ce0fb50728", "rev": "1edfe6d91bd8348cfccacd72e82d1d06ad470117",
"type": "github" "type": "github"
}, },
"original": { "original": {