A modult a Modul:table of contents/doc lapon tudod dokumentálni
local export = {}
local function makeUrl(title, queryType, from)
if title and title.fullUrl then
if from then
if queryType then
local query = { = from }
return title:fullUrl(query, "https")
else
return title:fullUrl(nil, "https")
end
end
end
end
local function link(title, queryType, from, display, script)
local url = makeUrl(title, queryType, from)
if url then
local ext_link = ""
if script then
return '<span class="' .. script .. '">' .. ext_link .. "</span>"
else
return ext_link
end
end
end
function export.show(frame)
local output = {}
local queryType
local params = {
= { list = true },
= { type = "boolean" },
= {},
= {}, -- for Coptic
}
local args = require("Module:parameters").process(frame.args and frame.args or frame:getParent().args, params)
local title = mw.title.getCurrentTitle()
local froms = args
local display = {}
local all_linktext = {}
for i, from in pairs(froms) do
if mw.ustring.match(from, ":") then
local from, linktext = mw.ustring.match(from, "(+):(.+)")
if from then
froms = from
display = linktext
table.insert(all_linktext, linktext)
else
error('Parameter ' .. i .. ' is badly formatted. It should contain a key to use in the link, a colon, and then the displayed text.')
end
end
end
local all_linktext = table.concat(all_linktext)
local script = require "Module:scripts".findBestScriptWithoutLang(all_linktext)
mw.log(all_linktext, script)
if args.CopticDisplay then
for character in mw.ustring.gmatch(args.CopticDisplay, ".") do
table.insert(display, character)
end
end
local subcat = args.subcat
if subcat then
queryType = "subcatfrom"
-- ]
require("Module:debug").track("table-of-contents/subcat")
else
queryType = "from"
end
if args.top then
local link = link(title, nil, args.top, nil)
table.insert(output, link)
end
if args.top and froms and froms then
table.insert(output, " – ")
end
for i, from in ipairs(froms) do
local link = link(title, queryType, from, display, script)
table.insert(output, link)
end
return table.concat(output, " ")
end
return export