Module:lnk-pro-morph: Difference between revisions
Jump to navigation
Jump to search
TheNightAvl (talk | contribs) (Created page with "local export = {} local getArgs = require("Module:Arguments").getArgs local data = mw.loadData("Module:lnk-pro-morph/data") local m_links = require("Module:links") local m_languages = require("Module:languages") local function get_form(form) end function export.show(frame) local args = getArgs(frame) end return export") |
TheNightAvl (talk | contribs) No edit summary |
||
(22 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
local export = {} | local export = {} | ||
local getArgs = require("Module:Arguments").getArgs | local getArgs = require("Module:Arguments").getArgs | ||
local data = mw.loadData("Module:lnk-pro-morph/data") | local data = mw.loadData("Module:lnk-pro-morph/data").citation | ||
local m_links = require("Module:links") | local m_links = require("Module:links") | ||
local m_languages = require("Module:languages") | local m_languages = require("Module:languages") | ||
local function get_form(form) | local function get_form(form) | ||
local replace = "" | |||
-- processes arguments of the form -Vn:o | |||
if mw.ustring.find(form, "[^%:]%:[^%:]") then | |||
form, replace = mw.ustring.match(form, "([^%:]+)%:([^%:]+)") | |||
end | |||
if not data[form] then | |||
if mw.ustring.find(form, "%-%-") then | |||
local cite = mw.ustring.gsub(form, "%-%-", "") | |||
local link = m_links.full_link{ | |||
term = cite .. "-", | |||
alt = cite, | |||
language = m_languages.get_by_code("lnk-pro"), | |||
nostar = true, | |||
} | |||
if mw.ustring.find(form, "^%-%-") then | |||
return "=" .. link | |||
elseif mw.ustring.find(form, "%-%-$") then | |||
return link .. "=" | |||
else | |||
error("-- needs to be either at the beginning or the end of the argument") | |||
end | |||
elseif mw.ustring.find(form, "%-") then | |||
return form | |||
else | |||
return "'''" .. form .. "'''" | |||
end | |||
end | |||
local link = data[form] | |||
if replace ~= "" then | |||
form = mw.ustring.gsub(form, "[CV]", replace) | |||
end | |||
return m_links.full_link{ | |||
term = link, | |||
alt = form, | |||
language = m_languages.get_by_code("lnk-pro"), | |||
nostar = true, | |||
} | |||
end | end | ||
function export.show(frame) | function export.show(frame) | ||
local args = getArgs(frame) | local args = getArgs(frame) | ||
local display = {} | |||
for _, arg in ipairs(args) do | |||
table.insert(display, get_form(arg)) | |||
end | |||
return "*" .. table.concat(display) | |||
end | end | ||
return export | return export |
Latest revision as of 12:46, 31 May 2024
local export = {}
local getArgs = require("Module:Arguments").getArgs
local data = mw.loadData("Module:lnk-pro-morph/data").citation
local m_links = require("Module:links")
local m_languages = require("Module:languages")
local function get_form(form)
local replace = ""
-- processes arguments of the form -Vn:o
if mw.ustring.find(form, "[^%:]%:[^%:]") then
form, replace = mw.ustring.match(form, "([^%:]+)%:([^%:]+)")
end
if not data[form] then
if mw.ustring.find(form, "%-%-") then
local cite = mw.ustring.gsub(form, "%-%-", "")
local link = m_links.full_link{
term = cite .. "-",
alt = cite,
language = m_languages.get_by_code("lnk-pro"),
nostar = true,
}
if mw.ustring.find(form, "^%-%-") then
return "=" .. link
elseif mw.ustring.find(form, "%-%-$") then
return link .. "="
else
error("-- needs to be either at the beginning or the end of the argument")
end
elseif mw.ustring.find(form, "%-") then
return form
else
return "'''" .. form .. "'''"
end
end
local link = data[form]
if replace ~= "" then
form = mw.ustring.gsub(form, "[CV]", replace)
end
return m_links.full_link{
term = link,
alt = form,
language = m_languages.get_by_code("lnk-pro"),
nostar = true,
}
end
function export.show(frame)
local args = getArgs(frame)
local display = {}
for _, arg in ipairs(args) do
table.insert(display, get_form(arg))
end
return "*" .. table.concat(display)
end
return export