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
Line 16:
if not seen[title] then
seen[title] = true
local page = mw.title.new(title)
-- look up the Definition: namespace version
local defTitle = "Definition:" .. title
local countpage = 0mw.title.new(defTitle)
if page and page.exists then
local text = page:getContent() or ""
-- strip templates, andget cleanfirst upsentence
text = text:gsub("%b{}", "")
text = text:gsub("^%s+", "")
local sentence = text:match("^(.-%.)")
--if collectsentence up to 3 sentencesthen
local sentences = {}
local count = 0
for sentence in text:gmatch("([^%.]+%.)") do
sentence = mw.text.trim(sentence)
if sentence ~= "" then
count = count + 1
table.insert(sentences, sentence)
if count >= 3 then
break
end
end
end
if #sentences > 0 then
table.insert(entries, {
title = title,
summary = table.concat(sentences, " ")sentence
})
end