Remove unused scripts

This commit is contained in:
Danila Fedorin 2022-03-27 18:48:06 -07:00
parent ac1eec35ec
commit 982ef99a2f
2 changed files with 0 additions and 47 deletions

View File

@ -1,36 +0,0 @@
require "open3"
require "nokogiri"
require "net/http"
require "json"
def render_cached(cache, display, string, render_comment = nil)
cache.fetch(string) do |new|
puts " Rendering #{render_comment || new}"
res = Net::HTTP.post URI("http://localhost:8000/render"),
{ :equations => [ { :str => string, :display => display } ] }.to_json,
"Content-Type" => "application/json"
cache[string] = JSON.parse(res.body)[0]
end
end
def perform_katex_sub(inline_cache, display_cache, content)
rendered = content.gsub /\\\(((?:[^\\]|\\[^\)])*)\\\)/ do |match|
render_cached(inline_cache, false, $~[1])
end
rendered = rendered.gsub /\$\$((?:[^\$]|$[^\$])*)\$\$/ do |match|
render_cached(display_cache, true, $~[1], "display")
end
return rendered
end
files = ARGV[0..-1]
inline_cache, display_cache = {}, {}
files.each do |file|
puts "Rendering file: #{file}"
document = Nokogiri::HTML.parse(File.open(file))
document.search('//*[not(ancestor-or-self::code)]/text()').each do |t|
t.replace(perform_katex_sub(inline_cache, display_cache, t.content))
end
File.write(file, document.to_html(encoding: 'UTF-8'))
end

View File

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