#!/bin/lua gsub = string.gsub pre = 0 if arg[1] == "-p" then pre = 1 table.remove(arg,1) end f = io.stdin if #arg ~= 0 then file = arg[1] f = io.open(file) end s = f:read("*a") -- print(s) f:close() if pre == 0 then s = gsub(s,"
\n","\n\n") s = gsub(s,"
\n$","") s = gsub(s,"(<[^>]+>)","") s = gsub(s,"\n\n\n+","\n\n") conv = {[">"] = ">", ["<"] = "<", ["&"] = "&", [" "] = " "} else conv = {[">"] = ">", ["<"] = "<", ["&"] = "&"} end s = gsub(s,"(&%w+;)",conv) print(s)