Module:Glossary: Difference between revisions
Content deleted Content added
No edit summary |
No edit summary |
||
| (2 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 ""
Line 8 ⟶ 9:
local seen = {}
local entries = {}
local
for link in content:gmatch("%[%[([^%]|]+)") do
local title = link:match("^(.-)#") or link
title = mw.text.trim(title)
Line 17 ⟶ 22:
seen[title] = true
local defTitle
defTitle = title
▲ if not page then
table.insert(debug, "FAIL mw.title.new: " .. defTitle)▼
elseif not page.exists then▼
else
end▼
local text = page:getContent()
if
▲ else
text = text:gsub("%b{}", "")
text = text:gsub("^%s+", "")
local sentence = text:match("^(.-%.)")
if
▲ else
table.insert(debug, "OK: " .. defTitle)▼
table.insert(entries, {
title = title:gsub("^Definition:", ""),
summary = sentence
})
end
end
Line 51 ⟶ 53:
local out = {}
▲ end
for _, e in ipairs(entries) do
table.insert(out,
▲ ))
end
| |||