#!/usr/bin/env lua -- -- Yoink -- Run this script to convert the manual page to html. -- function showhelp() print("Usage: "..arg[0].." [-eh] [-i manpage] [-o htmlfile]") print(" Convert the manual page to html with groff.") print("") print(" -e Hide email addresses in the manual page.") print(" -h Show this help an exit.") print(" -i Specify the manual page to convert.") print(" -o Specify output path of html file.") end ----- function die(...) print("die:", ...); os.exit(1) end function isReadable(file) return os.execute("test -r "..file) == 0 end arg.hideEmail = false arg.output = "yoink.html" arg.input = "yoink.6" if not isReadable(arg.input) then arg.input = "doc/yoink.6" end do local t = { ["-e"] = function(a,i) a.hideEmail = true end, ["-h"] = function(a,i) showhelp(); os.exit() end, ["-i"] = function(a,i) a.input = a[i+1]; return 1 end, ["-o"] = function(a,i) a.output = a[i+1]; return 1 end } function parseArgs(args) local skip = 0 for i,v in ipairs(args) do if skip <= 0 then if type(t[v]) ~= "function" then print("unknown option: "..v) showhelp(); os.exit(1) end skip = t[v](args, i) if tonumber(skip) then skip = skip + 1 else skip = 1 end end skip = skip - 1 end end end parseArgs(arg) filters = { function(t) -- 1. Edit page title return t:gsub("(