A modult a Modul:ne-utilities/doc lapon tudod dokumentálni

local export = {}

local lang = require("Module:languages").getByCode("ne")
local m_translit = require("Module:ne-translit")

function export.show(frame)
	PAGENAME = mw.title.getCurrentTitle().text
	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 (mw.ustring.match(args[1] or "", "[ऀ-ॿ]") and args[1] or nil); if head == "" then head = nil end
	
	local data = {lang = lang, pos_category = poscat, categories = {}, heads = {head}, translits = {args["tr"]}}
	
	local pron = args["pron"]
	local note = ""
	
	if not args["tr"] then
		if poscat == "nouns" or poscat == "proper nouns" then
			data.translits[1] = m_translit.tr(head or PAGENAME, "ne", "Deva", true)
		else
			data.translits[1] = m_translit.tr(head or PAGENAME, "ne", "Deva")
		end
	end
	
	local no_pron_arg = not pron and true or false
	
	if not pron and mw.ustring.match(head or PAGENAME, "[ीूईशषण]") then
		pron = mw.ustring.gsub(head or PAGENAME, "[ीईूण]", { ["ी"] = "ि", ["ई"] = "इ", ["ू"] = "ु", ["ण"] = "न" } )
		pron = mw.ustring.gsub(pron, "[शष]", "स")
	end
	
	if pron then
		note = ", ''pronounced ''"
		first = true
		for item in mw.text.gsplit(pron, ",", true) do
			if no_pron_arg and poscat == "nouns" then
				item = "<" .. item .. ">"
			end
			if not first then
				note = note .. " ''or'' "
			else
				first = false
			end
			note = note .. mw.ustring.gsub(item, "[<>]", "") .. ' (' .. m_translit.tr(item, "ne", "Deva") .. ')'
		end
	end
	
	data.heads[1] = head and mw.ustring.gsub(head, "[<>\-]", "") or nil
	
	return require("Module:headword").full_headword(data) .. note
end

function export.usex(frame)
	local args = frame:getParent().args
	local pagename = mw.title.getCurrentTitle().text
	local text = {}
	local example = args[1] or error("Example has not been specified. Please pass parameter 1 to the module invocation.")
	local translation = args[2] or ""
	local m_links = require("Module:links").remove_links

	if (not mw.ustring.match(example, "'''")) and mw.ustring.match(example, pagename) then
		example = mw.ustring.gsub(example, pagename, "'''" .. pagename .. "'''")
	end	
	local translit = m_translit.tr(m_links(example), "ne", "Deva")
	example = mw.ustring.gsub(example, "[<>]", "")

	table.insert(text, ('<span lang="ne" class="Deva">%s</span>'):format(example))
	if mw.ustring.match(example, "[\.\?!।]") then
		table.insert(text, "<dl><dd>''" .. translit .. "''</dd><dd>" .. translation .. "</dd></dl>")
	else
		table.insert(text, "&nbsp; ―&nbsp; ''" .. translit .. "''&nbsp; ―&nbsp; " .. translation)
	end
	return table.concat(text)
end

function export.link(frame)
	if type(frame) == "table" then
		args = frame:getParent().args
		text = args[1]
		def = args[2] or false
		vert = args["v"] or false
	else
		text = frame
	end
	text = ('<span lang="ne" class="Deva">[[%s#Nepali|'):format(mw.ustring.gsub(text, "[<>]", "")) .. 
		('%s]]</span>'):format(mw.ustring.gsub(text, "[<>]", "")) ..
		(vert and "<div style=\"line-height:1pt; font-size:90%; color:#888\"><br>" or " (") .. m_translit.tr(text, "ne", "Deva") .. 
		(def and ', “' .. def .. '”' or "") .. (vert and "</div>" or ")")
	return text
end

return export