বিষয়বস্তুতে চলুন

মডিউল:definition

উইকিঅভিধান, মুক্ত অভিধান থেকে

এই মডিউলের জন্য মডিউল:definition/নথি-এ নথিপত্র তৈরি করা হয়ে থাকতে পারে

--[=[

Module for implementing miscellaneous definition-line templates. Currently supports
only &lit.

Author: Benwing2
]=]--

local export = {}

local m_links = require("Module:links")

-- Uppercase first letter.
local function ucfirst(text)
	return mw.ustring.upper(mw.ustring.sub(text, 1, 1)) .. mw.ustring.sub(text, 2)
end

local function is_valid_page_name(pagename)
	return not not mw.title.new(pagename)
end

-- Implementation of {{&lit}}
function export.and_lit(terms, qualifier, dot, nodot, nocap)
	local output = {}
	table.insert(output, '<span class="use-with-mention">')
	if qualifier then
		table.insert(output, ucfirst(qualifier) .. " used")
	elseif nocap then
		table.insert(output, "used")
	else
		table.insert(output, "Used")
	end
	table.insert(output, " other than figuratively or idiomatically")
	if #terms > 0 then
		table.insert(output, "&#x3a; ")
		if terms[1].term == "-" or not is_valid_page_name(terms[1].term) then
			table.insert(output, terms[1].term)
			table.insert(output, "[[Category:&lit not valid pagename]]")
		else
			for i, term in ipairs(terms) do
				if i == 1 then
					table.insert(output, "''see'' ")
				else
					table.insert(output, ",&lrm; ")
				end
				table.insert(output, m_links.full_link(term, nil, nil))
			end
		end
	else
		table.insert(output, "[[Category:&lit without 1]]")
	end
	if not nodot then
		table.insert(output, dot or ".")
	end
	table.insert(output, "</span>")
	return table.concat(output)
end

return export