Module:Link:修订间差异

来自Arcaea中文维基
无编辑摘要
无编辑摘要
第25行: 第25行:
a,b,c = text:match('([^\s]*) (vs) ([^\s]*)') 
a,b,c = text:match('([^\s]*) (vs) ([^\s]*)') 
if a and b and c then
return link(page,a)..' '..b..' '..link(page,c)
end
a,b,c = text:match('([^\s]*) (×) ([^\s]*)')
if a and b and c then
if a and b and c then
return link(page,a)..' '..b..' '..link(page,c)
return link(page,a)..' '..b..' '..link(page,c)

2021年5月17日 (一) 23:20的版本

可在Module:Link/doc创建此模块的帮助文档

local p = {}

function p.titular(frame)
	local result=""
	args=mw.getCurrentFrame():getParent().args
	for i,k in ipairs(args) do
		result=result..'<span id="'..k..'"></span>'
	end
	return result
end

function link(page,name)
	local result= '[['..page..'列表#'..name..'|'..name..']]'
	return result
end

function p.link(frame)
	local page,text=mw.getCurrentFrame():getParent().args[1],mw.getCurrentFrame():getParent().args[2]
	local a,b,c
	
	a,b = text:match('([^\s]*) (feat.*)') 
	if a and b then
		return link(page,a)..' '..b
	end
	
	a,b,c = text:match('([^\s]*) (vs) ([^\s]*)') 
	if a and b and c then
		return link(page,a)..' '..b..' '..link(page,c)
	end
	
	a,b,c = text:match('([^\s]*) (×) ([^\s]*)') 
	if a and b and c then
		return link(page,a)..' '..b..' '..link(page,c)
	end

	a,b,c = text:match('([^\s]*) (vs.) ([^\s]*)') 
	if a and b and c then
		return link(page,a)..' '..b..' '..link(page,c)
	end

	return link(page,text)
end

return p