Module:Excerpt/sandbox: Difference between revisions

Content deleted Content added
parsecaption(): return entire caption when no terminator found
Remove dependency from Module:Redirect for easier porting to new wikis
Line 59:
 
local p = {}
local mRedirect = require('Module:Redirect')
 
-- Get a redirect target (or nil if not a redirect) without using the expensive title object property .isRedirect
Line 65 ⟶ 64:
local content = titleObject:getContent()
if not content then return nil end
local target = string.match(
return mRedirect.getTargetFromText(content)
text,
"^%s*#[Rr][Ee][Dd][Ii][Rr][Ee][Cc][Tt]%s*:?%s*%[%[([^%[%]|]-)%]%]"
) or string.match(
text,
"^%s*#[Rr][Ee][Dd][Ii][Rr][Ee][Cc][Tt]%s*:?%s*%[%[([^%[%]|]-)|[^%[%]]-%]%]"
)
return target
end