From 3026a05a2a2be91aa160de230a838acd5c2b3536 Mon Sep 17 00:00:00 2001 From: delta Date: Tue, 27 Jan 2026 04:18:15 +0100 Subject: woohoo no more bash components --- .zs/posthook.highlight | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 .zs/posthook.highlight (limited to '.zs/posthook.highlight') diff --git a/.zs/posthook.highlight b/.zs/posthook.highlight new file mode 100755 index 0000000..f1f2b74 --- /dev/null +++ b/.zs/posthook.highlight @@ -0,0 +1,45 @@ +#!/usr/bin/env lua + +-- local yah_bin = io.open("yah/target/release/yah", "r") +-- if yah_bin then +-- yah_bin:close() +-- else +-- os.execute("cd yah && cargo build --release") +-- end +-- +-- local _handle = assert(io.popen("find '" .. os.getenv("ZS_OUTDIR") .. "' -type f -name '*.html' -print0")) +-- ---@type string +-- local _files = _handle:read("*a") +-- _handle:close() +-- +-- local tmp = os.tmpname() +-- for file in _files:gmatch("(.-)\0") do +-- local handle = assert(io.open(file, "r+")) +-- ---@type string +-- local content = handle:read("*a") +-- content:gsub([[
(.-)
]], function(lang, code) +-- +-- local tmp_handle = assert(io.open(tmp, "w+")) +-- tmp_handle:write(code):close() +-- +-- local yah, err = io.popen([[yah/target/release/yah "]] .. lang .. [[" "]] .. tmp .. [["]], "r") +-- if err then +-- return [[
FAILED TO PARSE FILE, (ERR: ]] .. err .. [[)
]] +-- end +-- assert(yah) +-- +-- ---@type string +-- local out = yah:read("*a") +-- print(lang, tmp) +-- print(out) +-- +-- yah:close() +-- +-- return [[
]] .. out .. [[
]] +-- end) +-- -- print(content) +-- handle:close() +-- -- handle:seek("set") +-- -- handle:write(content):close() +-- end +-- -- os.remove(tmp) -- cgit v1.2.3