require "r2h2_modified" require "quick-terminal-customization" require "get_words" words = getWords("heonian-content/words") input = arg[1] or "input.txt" function apply(text) print(text) end function printD(...) io.stderr:write( string.effect( TERMINAL_EFFECT.Bold, string.color( TERMINAL_COLOR.HighPurple, "\tDEBUG:\t" ) ) .. string.color( TERMINAL_COLOR.HighPurple, table.unpack({...}) , "\n" ) ) end function printW(...) io.stderr:write( string.effect( TERMINAL_EFFECT.Bold, string.color( TERMINAL_COLOR.HighYellow, "\t WARN:\t" ) ) .. string.color( TERMINAL_COLOR.HighYellow, table.unpack({...}) .. "\n" ) ) end function printE(...) io.stderr:write( string.effect( TERMINAL_EFFECT.Bold, string.color( TERMINAL_COLOR.HighRed, "\tERROR:\t" ) ) .. string.color( TERMINAL_COLOR.HighRed, table.unpack({...}) .. "\n" ) ) end function process_content(content) content = content .. " " for i=1, 2 do if i == 1 then apply_html("html/convo/text/start_roman.html") else apply_html("html/convo/text/start_heonian.html") end local ac = check_symbol(content) while string.find(ac, " ") do local new_word = string.sub(ac, 0, string.find(ac, " ")-1) local indicators = {} if i == 1 then print_text = new_word else print_text = mod_convertToHeonian(new_word) end new_word = strip_symbols(new_word) new_word, indicators = revert_verbs(new_word, indicators) new_word, indicators = revert_nouns(new_word,indicators) new_word, indicators = categorize_word(new_word,indicators) add_word(new_word) local REPLACE_WORD = strip_symbols(print_text) local REPLACE_SEARCH = new_word local REPLACE_PRINT = print_text local REPLACE_DATA = "" local k = 0 for _, v in pairs(indicators) do if k > 0 then REPLACE_DATA = REPLACE_DATA .. " " end REPLACE_DATA = REPLACE_DATA .. v k = k + 1 end local html_stuff = [[ REPLACE_PRINT ]] while string.find(html_stuff, "REPLACE_PRINT") do html_stuff = string.gsub(html_stuff, "REPLACE_PRINT", REPLACE_PRINT) end while string.find(REPLACE_WORD, "%\'") do REPLACE_WORD = string.gsub(REPLACE_WORD, "%\'", "$") end while string.find(REPLACE_WORD, "%$") do REPLACE_WORD = string.gsub(REPLACE_WORD, "%$", "\\\'") end while string.find(html_stuff, "REPLACE_WORD") do html_stuff = string.gsub(html_stuff, "REPLACE_WORD", REPLACE_WORD) end while string.find(html_stuff, "REPLACE_SEARCH") do html_stuff = string.gsub(html_stuff, "REPLACE_SEARCH", REPLACE_SEARCH) end if REPLACE_DATA and REPLACE_DATA ~= "" then while string.find(REPLACE_DATA, "\t") do REPLACE_DATA = string.gsub(REPLACE_DATA, "\t", " ") end while string.find(html_stuff, "REPLACE_DATA") do html_stuff = string.gsub(html_stuff, "REPLACE_DATA", REPLACE_DATA) end else html_stuff = string.gsub(html_stuff, ",'REPLACE_DATA'","") end apply(html_stuff) ac = string.sub(ac, string.find(ac, " ")+1) -- now we print the thing with teh appropiate indicators. -- printD(print_text, table.unpack(indicators)) end apply_html("html/convo/text/end.html") end end function cell_builder(...) arg = {...} for i=1, #arg do apply_html("html/words/definition/cell_start.html") apply(arg[i]) apply_html("html/words/definition/cell_end.html") end end function print_word_stuff(word) apply_html("html/words/definition/start.html") local exit = false for _, v in pairs(words) do if strip_symbols(v[1]) == strip_spaces(word) then cell_builder(mod_convertToHeonian(word),v[1],v[3],v[2]) exit = true end end if not exit then -- personal pronuns local PP = { {"re","re","the speaker"," and someone else the listener doesn't know about"}, {"ba","ba","the listener"," and someone else the speaker doesn't know about"}, {"ima","ma","someone else","s who neither the speaker or the listener know about"} } for _, v1 in pairs(PP) do for _, v2 in pairs(PP) do if word == v1[1]..v2[2] then exit = true cell_builder( mod_convertToHeonian(word), word, "Pronoun", "This word refers to both "..v1[3] .. v2[4] .. ". \n\nIf in plural form, it refers to a group of people who all fit this definition." ) end end end if not exit then cell_builder(mod_convertToHeonian(word),word, "???","???") printW("\"" .. word .. "\" is not known") end end apply_html("html/words/definition/end.html") end function add_word(str) local add = true for _, v in pairs(word_list) do if v == str then add = false end end if add then table.insert(word_list,str) end end function strip_spaces(str) while string.find(str, "% ") do str = string.gsub(str, " ","") end return str end function strip_symbols(str) local symbol_table = "'~()!?:> 0 do p = string.find(text,"\n",p+1) skip = skip - 1 end else break end end convo_end() -- 3.5 separation apply_html("html/spacer.html") -- fourth lets make word lists -- process contents -- lets print the words apply_html("html/spacer.html") apply_html("html/words/start.html") for i=1, #word_list do print_word_stuff(word_list[i]) end apply_html("html/words/end.html") -- pop up apply_html("html/pop_up.html") -- lets end the html apply_html("html/end.html")