-- convert changelog to HTML local function find_header(buffer, position) local start, stop, date, author, email = buffer:find("(%d+%-%d+%-%d+)%s+(.-)%<([^%>]+)%>", position) return start, stop + 1, date, author, email end local function parse_entry(buffer, position) local _, pos, date, author, email = find_header(buffer, position) local entry = {date = date, author = author, email = email} -- find text between two headers local next_header = find_header(buffer, pos) entry.text = buffer:sub(pos, next_header - 1) return entry, pos + 1 end local escapes = {["<"] = "<", [">"] = ">", ["&"] = "&"} local function print_entry(entry) -- print just the date and the entry text print("") print("".. entry.date .. "") local end_par = "" local escaped = entry.text:gsub("([%<%>%&])", function(a) return escapes[a] end) local text = escaped--:gsub("^%s*", "") -- remove space at the beginning :gsub("\n%s*%*%s+", function(star) -- replace "*" characters with paragraphs in the changelog entry local replace = end_par .. "

" end_par = "\n

\n" return replace end) :gsub("%s*$", "") -- remove space at the end .. "\n

" -- we need to close the paragraph explicitly -- text = text:gsub("

(.-):", "

%1:") -- escape links text = text:gsub("(http[^%s]+)", "
%1") -- escape file names text = text:gsub("([a-zA-z0-9%-%.]+tex)%s+(%([^%)]+%))", function(texfile, generated) texfile = string.format("%s", texfile, texfile) return texfile .. " " .. generated end) print("") print(text) print("\n") end -- read the standard input local buffer = io.read("*all") -- initialize variables local pos = 0 local entry, entries = nil, {} local news_entries = tonumber(arg[1]) or 2 -- number of printed changelog entries -- parse changelog for _=1,news_entries do entry, pos = parse_entry(buffer, pos) entries[#entries+1] = entry end -- it is not really clean to just print it, but I don't feel a necessity to use -- templates yet print("") -- print parsed entries for _, entry in ipairs(entries) do print_entry(entry) end print("
")