Module:Glossary: Difference between revisions
Content deleted Content added
Created page with "-- Module:AutoGlossary local p = {} function p.generate(frame) local current = mw.title.getCurrentTitle() local content = current:getContent() or "" -- find all internal links local seen = {} local entries = {} for link in content:gmatch("%[%[([^%]|]+)") do local title = link:match("^(.-)#") or link title = mw.text.trim(title) if not seen[title] then seen[title] = true local p..." |
No edit summary |
||
| (4 intermediate revisions by the same user not shown) | |||
Line 3:
function p.generate(frame)
local maxEntries = tonumber(frame.args[1]) or 30
local current = mw.title.getCurrentTitle()
local content = current:getContent() or ""
local seen = {}
local entries = {}
local count = 0
for link in content:gmatch("%[%[([^%]|]+)") do
local title = link:match("^(.-)#") or link
title = mw.text.trim(title)
Line 16 ⟶ 21:
if not seen[title] then
seen[title] = true
if
if page
if text
table.insert(entries, {▼
count = count + 1
▲ if count >= 3 then
▲ break
▲ end
end
▲ end
▲ if #sentences > 0 then
▲ table.insert(entries, {
▲ title = title,
▲ summary = table.concat(sentences, " ")
▲ })
end
end
Line 47 ⟶ 48:
end
table.sort(entries, function(a, b)
return a.title < b.title
end)
local out = {}
for _, e in ipairs(entries) do
table.insert(out,
▲ ))
end
| |||