Module:Hagnon/tåvlea

Èn årtike di Wiccionaire.
I gn a nén co di dzo-pådje /doc pol notule d’ esplikêyes. Clitchîz cial po l’ ahiver.
local p = {}

function p.build_html_table()
	
	-- get the table of titles
    local titles = mw.loadData('Module:Hagnon/data')
	
	-- sort by name
	local titles_sorted = {}
	for name, _ in pairs(titles["text"]) do
		table.insert(titles_sorted, name)
	end
	table.sort(titles_sorted)
	
	html = '<table class="wikitable" style="width:100%;">'
	html = html .. "<tr><th>Tite</th><th>Côde</th><th>Rascourtis</th><th>Livea</th></tr>"
	for _, name in pairs(titles_sorted) do
		local tab = titles['text'][name]
		local title_level = string.rep("=",tab["level"])
		local aliases = ""
		if tab['alias'] ~= nil then
			aliases = aliases .. "<ul>"
			for i, alias in pairs(tab['alias']) do
				aliases = aliases .. "<li>" .. alias .. "</li>"
			end
			aliases = aliases .. "</ul>"
		end
		html = html .. "<tr>"
		html = html .. "<td>"..tab["name"].."</td>"
		html = html .. "<td><code>"..title_level.."{{H|"..name.."}}"..title_level.."</code></td>"
		html = html .. "<td>"..aliases.."</td>"
		html = html .. "<td>"..tab["level"].."</td>"
		html = html .. "</tr>"
	end
	html = html .. "</table>"	
		
	return html
end

return p