function apply_html(path)
-- copy
local file = io.open(path,"r")
local html = file:read("*all")
file:close()
-- paste
print(html)
end
function convo_start(color)
if not convo then
if color then
apply_html("html/convo/start_green.html")
else
apply_html("html/convo/start_gray.html")
end
convo = true
end
end
function convo_end()
if convo then
apply_html("html/convo/end.html")
convo = false
end
end
-- lets make the html
apply_html("html/start.html")
-- get text
local file = io.open("input.txt","r")
local text = file:read("*all")
file:close()
-- first analyze text
-- (this is the fun part)
local p = 0
local s = 0
local convo = false
local green = true
while p ~= nil do
s = s + 1
local np = string.find(text,"\n",p+1)
if np and p - np ~= 1 then
if p then
if string.sub(text,p+1,p+1) == "\n"
or string.sub(text,p+1,p+1) == "/" then
-- end of new bubble
convo_end()
elseif string.sub(text,p+1,p+1) == "\t" then
-- its tabbed so its spoken?
convo_start()
apply_html("html/convo/text/start.html")
print(string.sub(text,p+2,np-1))
apply_html("html/convo/text/end.html")
else
-- new user name
convo_end()
if green then
green = false
else
green = true
end
convo_start(green)
apply_html("html/convo/header/start.html")
apply_html("html/convo/header/name/start.html")
print(string.sub(text,p+1,np-1))
apply_html("html/convo/header/name/end.html")
apply_html("html/convo/header/end.html")
--print(s,string.sub(text,p+1,np))
end
else
--print(s,string.sub(text,p+1))
end
p = string.find(text,"\n",p+1)
else
break
end
end
apply_html("html/convo/end.html")
-- fourth lets make word lists
-- lets end the html
apply_html("html/end.html")