Use nokogiri to semantically replace math in HTML
This commit is contained in:
parent
13cf6263b0
commit
2364a0dcf6
|
@ -1,3 +1,15 @@
|
|||
source $stdenv/setup
|
||||
|
||||
# Install KaTeX for back-end rendering.
|
||||
HOME="." npm install katex
|
||||
|
||||
# Build site with Hugo
|
||||
cp -r $src/* .
|
||||
hugo --baseUrl="https://danilafe.com" --destination=$out
|
||||
hugo --baseUrl="http://localhost:5000"
|
||||
|
||||
# Render math in HTML and XML files.
|
||||
find public/ -regex "public/.*\.html" | xargs ruby $converter
|
||||
|
||||
# Output result
|
||||
mkdir $out
|
||||
cp -r public/* $out/
|
||||
|
|
|
@ -11,7 +11,7 @@ def perform_katex_sub(content)
|
|||
end
|
||||
end
|
||||
rendered = rendered.gsub /\$\$((?:[^\$]|$[^\$])*)\$\$/ do |match|
|
||||
puts " Rendering display #{$~[1][0..30].strip}"
|
||||
puts " Rendering display."
|
||||
Open3.popen3("$(npm bin)/katex -d") do |i, o, e, t|
|
||||
i.write $~[1]
|
||||
i.close
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
{ stdenv, hugo, fetchgit }:
|
||||
{ stdenv, hugo, fetchgit, nodejs, ruby }:
|
||||
|
||||
let
|
||||
url = "https://dev.danilafe.com/Web-Projects/blog-static.git";
|
||||
rev = "b04d82f0b3d949c1d4cd64246cc9c9558241f9ed";
|
||||
sha256 = "02w05ff3mb8x3x65822vzg8lil0q6w4rfkj098fa0lwv8wv6x4cy";
|
||||
rev = "7f3883fb3994f8ae1a64446a88b729662c9244dc";
|
||||
sha256 = "065by3rjg7a43dqdl5ib07c0xi86balb5x2l54jqnlh1hz00bd85";
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
name = "blog-static";
|
||||
|
@ -12,5 +12,6 @@ in
|
|||
inherit url rev sha256;
|
||||
};
|
||||
builder = ./builder.sh;
|
||||
buildInputs = [ hugo ];
|
||||
converter = ./convert.rb;
|
||||
buildInputs = [ hugo nodejs (ruby.withPackages (ps: [ ps.nokogiri ])) ];
|
||||
}
|
||||
|
|
Reference in New Issue
Block a user