Module:diacritical mark


local export = {}
local pos_functions = {}

local function track(page)
	require("Module:debug").track("diacritical mark/" .. page)
	return true
end

local function glossary_link(anchor, text)
	text = text or anchor
	return "[[Appendix:Glossary#" .. anchor .. "|" .. text .. "]]"
end

-- The main entry point.
-- This is the only function that can be invoked from a template.
function export.show(frame)
	local NAMESPACE = mw.title.getCurrentTitle().nsText
	local PAGENAME = mw.title.getCurrentTitle().text

	local iparams = {
		[1] = {required = true},
		["def"] = {},
		["sc"] = {},
		["sccat"] = {type = "boolean"}
	}
	local iargs = require("Module:parameters").process(frame.args, iparams)
	local lang = require("Module:languages").getByCode(iargs[1])
	local args = frame:getParent().args
	local poscat = "diacritical marks"
	local def = iargs.def
	local postype = poscat

	local data = {lang = lang, categories = {}, heads = {}, genders = {}, inflections = {}}

	if pos_functions[postype] then
		local new_poscat = pos_functions[postype](postype, def, args, data)
		if new_poscat then
			poscat = new_poscat
		end
	end

	data.pos_category = (NAMESPACE == "Reconstruction" and "reconstructed " or "") .. poscat
	
	local ret = require("Module:headword").full_headword(data)
	
	ret = mw.ustring.gsub(ret,"terms spelled with [^%]]+","lemmas")
	
	return ret
end

pos_functions["diacritical marks"] = function(postype, def, args, data)
	local params = {
		[1] = {required = true},
		[2] = {required = true, list = "head", default = def},
		["id"] = {},
		["sc"] = {},
		["sccat"] = {type = "boolean"}
	}

	local args = require("Module:parameters").process(args, params)

	data.heads = args[2]
	data.no_redundant_head_cat = true -- since 2= is required and goes into heads
	data.id = args.id
	data.sc = args["sc"] and require("Module:scripts").getByCode(args["sc"], "sc") or nil
	data.sccat = args["sccat"]
end

return export