Jump to content

Module:definition

Wiktionary වෙතින්


--[=[

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

Author: Benwing2
]=]--

local export = {}

local links_module = "Module:links"
local pages_module = "Module:pages"
local string_utilities_module = "Module:string utilities"

local concat = table.concat
local insert = table.insert
local require = require

--[==[
Loaders for functions in other modules, which overwrite themselves with the target function when called. This ensures modules are only loaded when needed, retains the speed/convenience of locally-declared pre-loaded functions, and has no overhead after the first call, since the target functions are called directly in any subsequent calls.]==]
	local function full_link(...)
		full_link = require(links_module).full_link
		return full_link(...)
	end

	local function is_valid_page_name(...)
		is_valid_page_name = require(pages_module).is_valid_page_name
		return is_valid_page_name(...)
	end
	
	local function ucfirst(...)
		ucfirst = require(string_utilities_module).ucfirst
		return ucfirst(...)
	end

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

return export
"https://si.wiktionary.org/w/index.php?title=Module:definition&oldid=225484" වෙතින් සම්ප්‍රවේශනය කෙරිණි