en:Module:InfoboxImage 03:22, 19 November 2014(UTC)より
template>Fryed-peach (en:Module:InfoboxImage 2014年8月10日 (日) 07:38 より) |
template>K-iczn (en:Module:InfoboxImage 03:22, 19 November 2014(UTC)より) |
||
92行目: | 92行目: | ||
-- change underscores to spaces | -- change underscores to spaces | ||
image = mw.ustring.gsub(image, "_", " "); | image = mw.ustring.gsub(image, "_", " "); | ||
assert(image ~= nil, 'mw.ustring.gsub(image, "_", " ") must not return nil') | |||
-- if image starts with [[ then remove that and anything after | | -- if image starts with [[ then remove that and anything after | | ||
if mw.ustring.sub(image,1,2) == "[[" then | if mw.ustring.sub(image,1,2) == "[[" then | ||
image = mw.ustring.sub(image,3); | image = mw.ustring.sub(image,3); | ||
image = mw.ustring.gsub(image, "([^|]*)|.*", "%1"); | image = mw.ustring.gsub(image, "([^|]*)|.*", "%1"); | ||
assert(image ~= nil, 'mw.ustring.gsub(image, "([^|]*)|.*", "%1") must not return nil') | |||
end | end | ||
-- Trim spaces | -- Trim spaces | ||
image = mw.ustring.gsub(image, '^[ ]*(.-)[ ]*$', '%1'); | image = mw.ustring.gsub(image, '^[ ]*(.-)[ ]*$', '%1'); | ||
assert(image ~= nil, "mw.ustring.gsub(image, '^[ ]*(.-)[ ]*$', '%1') must not return nil") | |||
-- remove prefix if exists | -- remove prefix if exists | ||
local allNames = mw.site.namespaces[6].aliases | local allNames = mw.site.namespaces[6].aliases |