Module:Sandbox/trappist the monk/ac code explained

require('strict');local p=

function p.ac_code (frame) local page = mw.title.getCurrentTitle; -- get a page object for this page local content = page:getContent; -- get unparsed content local out_table = ; -- table assembled tables local wiki_name; local icao;

for iata, iata_name in string.gmatch (content, "p%.IATA%['(%u%u%u)'%]='([^\n\r]-)'") do -- for each iata airport code line, get the code and airport name local temp_table = ;

wiki_name = mw.ustring.match (content, "p%.WikiName%['" .. iata .. "'%]='([^\r\n]+)'"); -- get the wiki article name that matches iata code local name = mw.ustring.gsub (iata_name, "([%(%)%.%%%+%-%*%?%[%^%$%]])", "%%%1") icao = mw.ustring.match (content, "p%.ICAO%['(%u%u%u%u)'%]='" .. name .. "'"); -- get the icao code that matches the iata airport name

if not icao then icao = end table.insert (temp_table, ''); table.insert (out_table, table.concat (temp_table)); end return "

return {<br />&#9;" .. table.concat (out_table, ',<br />&#9;') .. "<br />&#9;}<br />" .. "
";end

return p;