Module:Excerpt: Difference between revisions

Content deleted Content added
Remove {{Update}} and chums
Copy Morpeth imagemap fix (mostly by User:Evad37) from sandbox
Line 95:
if not hasNamedArgs then return nil end -- filter out any template that obviously doesn't contain an image
 
-- ensure image map is captured
text = mw.ustring.gsub(text, '<!%-%-imagemap%-%->', '|imagemap=')
 
Line 100 ⟶ 101:
local hasImages = false
local images = {}
local capture_from = 1
for position, image in mw.ustring.gmatch(text, "|%s*[^=|]-[Ii][Mm][Aa][Gg][Ee][^=|]-%s*=%s*()(.*)") do
while capture_from < mw.ustring.len(text) do
hasImages = true
for local argname, position, image in= mw.ustring.gmatchmatch(text, "|%s*([^=|]-[Ii][Mm][Aa][Gg][Ee][^=|]-)%s*=%s*()(.*)"), docapture_from)
images[position] = image
if image then -- ImageCaption=, image_size=, image_upright=, etc. do not introduce an image
local lcArgname = mw.ustring.lower(argname)
if mw.ustring.find(lcArgname, "caption")
or mw.ustring.find(lcArgname, "size")
or mw.ustring.find(lcArgname, "upright") then
image = nil
end
end
if image then
hasImages = true
images[position] = image
capture_from = position
else
capture_from = mw.ustring.len(text)
end
end
capture_from = 1
for position, image in mw.ustring.gmatch(text, "|%s*[^=|]-[Pp][Hh][Oo][Tt][Oo][^=|]-%s*=%s*()(.*)") do
while capture_from < mw.ustring.len(text) do
hasImages = true
for local position, image in= mw.ustring.gmatchmatch(text, "|%s*[^=|]-[Pp][Hh][Oo][Tt][Oo][^=|]-%s*=%s*()(.*)"), docapture_from)
images[position] = image
if image then
end
hasImages = true
for position, image in mw.ustring.gmatch(text, "|%s*[^=|{}]-%s*=%s*()%[?%[?([^|{}]*%.%a%a%a%a?)%s*%f[|}]") do
hasImages = true
if not images[position] then
images[position] = image
capture_from = position
else
capture_from = mw.ustring.len(text)
end
end
capture_from = 1
while capture_from < mw.ustring.len(text) do
for local position, image in= mw.ustring.gmatchmatch(text, "|%s*[^=|{}]-%s*=%s*()%[?%[?([^|{}]*%.%a%a%a%a?)%s*%f[|}]"), docapture_from)
if image then
hasImages = true
if not images[position] then
images[position] = image
end
capture_from = position
else
capture_from = mw.ustring.len(text)
end
end
Line 119 ⟶ 149:
-- find all captions
local captions = {}
local capture_from = 01
while capture_from < #mw.ustring.len(text) do
local position, caption = mw.ustring.match(text, "|%s*[^=|]*[Cc][Aa][Pp][Tt][Ii][Oo][Nn][^=|]*%s*=%s*()([^\n]+)", capture_from)
if caption then
Line 143 ⟶ 173:
capture_from = position
else
capture_from = #mw.ustring.len(text)
end
end