Module:Find sources/sandbox: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Line 39:
return table.concat(searchStrings, separator)
end
local function extractTerms(args, title)
 
-- Get the search terms from the arguments.
local searchTerms = {}
for i, s in ipairs(args) do
searchTerms[i] = s
end
if not searchTerms[1] then
-- Use the current subpage name as the default search term. If the page
-- uses a disambiguator like "Foo (bar)", make "Foo" the first term and
-- "bar" the second.
local term, dab = title.subpageText:match('^(.*) (%b())$')
if dab then
dab = dab:sub(2, -2) -- Remove parens
end
if term and dab then
searchTerms[1] = term
searchTerms[2] = dab
else
searchTerms[1] = title.subpageText
end
end
searchTerms[1] = '"' .. searchTerms[1] .. '"'
return terms
end
function p._renderLink(code, searchTerms, display)
-- Renders the external link wikicode for one link, given the link code,
Line 80 ⟶ 103:
return p._renderLink(code, searchTerms, display)
end
 
local function extractTerms(args, title)
-- Get the search terms from the arguments.
local searchTerms = {}
for i, s in ipairs(args) do
searchTerms[i] = s
end
if not searchTerms[1] then
-- Use the current subpage name as the default search term. If the page
-- uses a disambiguator like "Foo (bar)", make "Foo" the first term and
-- "bar" the second.
local term, dab = title.subpageText:match('^(.*) (%b())$')
if dab then
dab = dab:sub(2, -2) -- Remove parens
end
if term and dab then
searchTerms[1] = term
searchTerms[2] = dab
else
searchTerms[1] = title.subpageText
end
end
searchTerms[1] = '"' .. searchTerms[1] .. '"'
return terms
end
function p._main(template, args)
-- The main access point from Lua.