Modul:R:ErtSz
A modult a Modul:R:ErtSz/doc lapon tudod dokumentálni
local export = {}
local term_module, homonym_module = "Module:R:ErtSz/data", "Module:R:ErtSz/homonyms"
local base_path = "https://www.arcanum.com/hu/online-kiadvanyok/Lexikonok-a-"
.. "magyar-nyelv-ertelmezo-szotara-1BE8B/"
local function _sense_and_link(term, number, sense)
local code
if not number then
local single_match = require(term_module)(term)
if not single_match then
local homonyms = require(homonym_module)(term)
if not homonyms then
local link = "[" .. base_path .. "]"
else
homonyms = require("Module:array")(homonyms)
local i = 0
local link = "[" .. base_path .. "]"
end
end
code = single_match
else
local homonyms = require(homonym_module)(term)
if not homonyms then
local link = "[" .. base_path .. "]"
end
code = homonyms[number]
if not code then
local link = "[" .. base_path .. "]"
end
end
if code then
local link = "[" .. base_path .. code .. " " .. term .. "]"
if sense then
return require("Module:qualifier").sense({sense}) .. " " .. link
else
return link
end
else
local link = "[" .. base_path .. " " .. term .. "]"
return link
end
end
function export.sense_and_link(frame)
local args = frame:getParent().args
local title = args.title and assert(mw.title.new(args.title)) or mw.title.getCurrentTitle()
-- Use args[1] as number if it's composed of only ASCII digits.
local term, number
if args[1] and args[1]:find "^%d+$" then
number = tonumber(args[1])
else
term = args[1]
if args[2] then
number = tonumber(args[2])
if not number then
local link = "[" .. base_path .. "]"
end
end
end
local sense = args[2]
if not term then
if title.nsText == "Template" then
return ""
else
term = title.text
end
end
return _sense_and_link(term, number, sense)
end
return export