Module:nyms: Difference between revisions

From Laenkea
Jump to navigation Jump to search
No edit summary
No edit summary
Line 15: Line 15:
table.insert(links, m_links.full_link{term = term, language = data.language})
table.insert(links, m_links.full_link{term = term, language = data.language})
end
end
return '<span class="nyms" data-label="' .. string.lower(data.label) .. '"><span class="nyms-label">' .. data.label .. ':</span> ' .. table.concat(links, ", ") .. '</span>'
return '<span class="nyms" data-label="' .. data.label .. '"><span class="nyms-label">' .. data.label:gsub("^%l", string.upper) .. ':</span> ' .. table.concat(links, ", ") .. '</span>'
end
end


function export.show_synonyms(frame)
function export.show(frame)
local args = m_parameters.process(frame:getParent().args, params)
local args = m_parameters.process(frame:getParent().args, params)
return export.make_nym_list{
return export.make_nym_list{
label = "Synonyms",
label = frame.args[1],
language = m_languages.get_by_code(args[1]),
terms = args[2],
}
end
 
function export.show_antonyms(frame)
local args = m_parameters.process(frame:getParent().args, params)
return export.make_nym_list{
label = "Antonyms",
language = m_languages.get_by_code(args[1]),
language = m_languages.get_by_code(args[1]),
terms = args[2],
terms = args[2],

Revision as of 17:54, 9 February 2024

Documentation for this module may be created at Module:nyms/documentation

local export = {}

local m_languages = require("Module:languages")
local m_links = require("Module:links")
local m_parameters = require("Module:parameters")

local params = {
	[1] = {required = true},
	[2] = {list = true},
}

function export.make_nym_list(data)
	local links = {}
	for _, term in ipairs(data.terms) do
		table.insert(links, m_links.full_link{term = term, language = data.language})
	end
	return '<span class="nyms" data-label="' .. data.label .. '"><span class="nyms-label">' .. data.label:gsub("^%l", string.upper) .. ':</span> ' .. table.concat(links, ", ") .. '</span>'
end

function export.show(frame)
	local args = m_parameters.process(frame:getParent().args, params)
	return export.make_nym_list{
		label = frame.args[1],
		language = m_languages.get_by_code(args[1]),
		terms = args[2],
	}
end

return export