更多操作
小 (上一次编辑本应包含的说明: 由于无法处理 <gallery>, 只得换用并不兼容原有画廊用法的方法) |
小无编辑摘要 |
||
第5行: | 第5行: | ||
local parent = frame:getParent() | local parent = frame:getParent() | ||
local arg = parent.args['image'] | local arg = parent.args['image'] | ||
if | |||
local gallery_mark_index = arg:find('gallery:') | |||
if gallery_mark_index ~= 1 then --< 单张图片 | |||
if string.byte(arg, 1) == 127 then | if string.byte(arg, 1) == 127 then | ||
return '<span style="font-size: 24px; color: red">\ | return '<span style="font-size: 24px; color: red">\ | ||
第16行: | 第18行: | ||
end | end | ||
-- 去掉 'gallery:' | |||
arg = string.sub(arg, 9, -1) | |||
for image_line in arg:gmatch('[^\r\n]+') do | for image_line in arg:gmatch('[^\r\n]+') do |
2019年1月15日 (二) 02:28的版本
此模块的文档可以在模块:Infobox/item/image/doc创建
local p = {}
function p.make()
local frame = mw.getCurrentFrame()
local parent = frame:getParent()
local arg = parent.args['image']
local gallery_mark_index = arg:find('gallery:')
if gallery_mark_index ~= 1 then --< 单张图片
if string.byte(arg, 1) == 127 then
return '<span style="font-size: 24px; color: red">\
不支持<gallery>语法</span>\
[[Category: 含有在信息框中使用了旧的画廊语法的页面]]'
end
return frame:expandTemplate{ title = 'Infobox/item/single image', args = {
image = arg, caption = parent.args['caption']
} }
end
-- 去掉 'gallery:'
arg = string.sub(arg, 9, -1)
for image_line in arg:gmatch('[^\r\n]+') do
-- table.insert(lines, line)
local sep = image_line:find(':')
table.insert(images, {
file = string.sub(image_line, 1, sep-1),
title = string.sub(image_line, sep+1, -1)
})
end
return mw.dumpObject(images) --< debug
end
return p