Modul:AufEinWortLeserschaft
Erscheinungsbild
-- Module:Leserschaft
local p = {}
local function trim(s)
if not s then return "" end
-- UTF-8 safe trim
return (mw.ustring.gsub(s, "^%s*(.-)%s*$", "%1"))
end
local function split_on_separators(s)
local parts = {}
if not s or s == "" then return parts end
-- akzeptiere Komma oder Semikolon als Trenner
for part in mw.ustring.gmatch(s, "[^,;]+") do
local t = trim(part)
if t ~= "" then table.insert(parts, t) end
end
return parts
end
function p.leserschaft(frame)
-- 1. Parameter: entweder als erstes arg oder als Named param Leserschaft
local input = frame.args[1] or frame:getParent().args.Leserschaft or ""
local names = split_on_separators(tostring(input))
if #names == 0 then return "" end
local sema = {}
local links = {}
for _, name in ipairs(names) do
-- normalisiere Leerraum (mehrfache Leerzeichen -> 1)
local page = mw.ustring.gsub(name, "%s+", " ")
-- Erzeuge Semantic-Property (wird unsichtbar gespeichert, falls du das möchtest)
table.insert(sema, "[[hat Leserschaft::" .. page .. "]]")
-- Sichtbarer Link zur Seite (rot, wenn Seite nicht existiert)
table.insert(links, "[[" .. page .. "]]")
end
-- gib zuerst die Property-Tags zurück (ohne sichtbaren Text) und dann die sichtbare Liste
return table.concat(sema, "") .. table.concat(links, ", ")
end
return p