Module:descendants: Difference between revisions
Jump to navigation
Jump to search
TheNightAvl (talk | contribs) (Created page with "--WORK IN PROGRESS -- local export = {} local getArgs = require("Module:Arguments").getArgs local m_links = require("Module:links") local m_languages = require("Module:languages") local m_inline = require("Module:inline") function export.descendant(frame) -- {{desc|rad|word1|word2...}} local args = getArgs(frame) local out = "" local lang = m_languages.get_by_code(args[1]) local borrowed = args["borrowed"] or args["bor"] or args["b"] local see_desc = args["s...") |
TheNightAvl (talk | contribs) No edit summary |
||
Line 16: | Line 16: | ||
local see_desc = args["see"] | local see_desc = args["see"] | ||
local noname = args["noname"] | local noname = args["noname"] | ||
local lostcap = args[" | local lostcap = args["lost"] or "lost" | ||
if borrowed then out = "<span class=\"desc-arrow\" title=\"borrowed\">→</span>" .. out end | if borrowed then out = "<span class=\"desc-arrow\" title=\"borrowed\">→</span>" .. out end | ||
Line 23: | Line 23: | ||
if args[2] then | if args[2] then | ||
local terms = {} | |||
local i = 2 | |||
while args[i] do | |||
local term, term_args = m_inline.parse(args[i]) | |||
table.insert(terms, m_links.full_link({ | |||
language = lang, | |||
term = term, | |||
alt = term_args.alt, | |||
anchor = term_args.anchor or term_args.a, | |||
gloss = term_args.t, | |||
pos = term_args.pos, | |||
nobold = true, | |||
}) | |||
) | |||
i = i + 1 | |||
end | |||
out = out .. table.concat(terms, ", ") | |||
if see_desc then out = out .. frame:expandTemplate{ title = 'see descendants' } end | if see_desc then out = out .. frame:expandTemplate{ title = 'see descendants' } end | ||
else | else |
Revision as of 23:52, 29 May 2024
Underlies {{descendant}}
and {{descendant tree}}
.
--[[
WORK IN PROGRESS
]]--
local export = {}
local getArgs = require("Module:Arguments").getArgs
local m_links = require("Module:links")
local m_languages = require("Module:languages")
local m_inline = require("Module:inline")
function export.descendant(frame) -- {{desc|rad|word1|word2...}}
local args = getArgs(frame)
local out = ""
local lang = m_languages.get_by_code(args[1])
local borrowed = args["borrowed"] or args["bor"] or args["b"]
local see_desc = args["see"]
local noname = args["noname"]
local lostcap = args["lost"] or "lost"
if borrowed then out = "<span class=\"desc-arrow\" title=\"borrowed\">→</span>" .. out end
if not noname then out = out .. lang.name .. ": " end
if args[2] then
local terms = {}
local i = 2
while args[i] do
local term, term_args = m_inline.parse(args[i])
table.insert(terms, m_links.full_link({
language = lang,
term = term,
alt = term_args.alt,
anchor = term_args.anchor or term_args.a,
gloss = term_args.t,
pos = term_args.pos,
nobold = true,
})
)
i = i + 1
end
out = out .. table.concat(terms, ", ")
if see_desc then out = out .. frame:expandTemplate{ title = 'see descendants' } end
else
out = out .. "— (''" .. lostcap .. "'')"
end
return out
end
return export
--[[
Debug console test string:
=p.descendant(mw.getCurrentFrame():newChild{title="whatever",args={"rad"}})
]]--