Module:tdd-headword

This module needs documentation.
Please document this module by describing its purpose and usage on the documentation page.

local export = {}
--local pos_functions = {}
local gsub = mw.ustring.gsub
local u = mw.ustring.char

local lang = require("Module:languages").getByCode("tdd")
local script = require("Module:scripts").getByCode("Tale")
local PAGENAME = mw.title.getCurrentTitle().text

local old_tones = {
	-- uses combining marks
	["ᥰ"] = u(0x0308), -- tone 2
	["ᥱ"] = u(0x030C), -- tone 3
	["ᥲ"] = u(0x0300), -- tone 4
	["ᥳ"] = u(0x0307), -- tone 5
	["ᥴ"] = u(0x0301), -- tone 1
	-- unmarked for [ptk] tone 5, else tone 6
}

function export.show(frame)

	local args = frame:getParent().args
	local poscat = frame.args[1] or error("Part of speech has not been specified. Please pass parameter 1 to the module invocation.")
 
	local head = args["head"] or PAGENAME
	local tr = args["tr"]
	
	local data = {lang = lang, pos_category = poscat, categories = {}, heads = {head}, translits = {tr}, inflections = {}}
	
	local old_ortho = {label = "1963 orthography"}
	local old_term = gsub(head, "[ᥰ-ᥴ]", old_tones)
	old_term = gsub(old_term, u(0x200C), "")
	old_term = gsub(old_term, "‌", "")
	old_term = gsub(old_term, u(0x200D), "")
	old_term = gsub(old_term, "‍", "")
	table.insert(old_ortho, {term = old_term})
	table.insert(data.inflections, old_ortho)
 
	return require("Module:headword").full_headword(data)

end

return export