ravenous.dev/tools/sitegen.lua

#!/usr/bin/env lua

local escs = {
	["<"] = "&lt;",
	[">"] = "&gt;",
	["&"] = "&amp;",
	['"'] = "&quot;",
}

function w(...)
	io.write(table.concat({...}, " "))
	io.flush()
end

function t(...)
	local s = table.concat({...}, " ")
	w((s:gsub(".", escs)))
end

function l(...)
	w(...)
	w "\n"
	io.flush()
end

local function run(file, ...)
	assert(loadfile(file))(...)
end

w [[
<!doctype html>
]]

w [[<html style="background-image: url(']]
w(("/flowers/%02d.gif"):format(math.random(12) + 1))
w [[');">]]

w [[
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="/style.css" />
]]
run(...)