Adjust the KaTeX script to skip rendering in <script> tags

This commit is contained in:
Danila Fedorin 2023-12-16 10:21:18 -08:00
parent 66dc28eca7
commit 9ddfb114c7

View File

@ -31,7 +31,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)]/text()').each do |t| document.search('//*[not(ancestor-or-self::code or ancestor-or-self::script)]/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'))