模块:Hydrogina/sandbox/NameInText
跳转到导航
跳转到搜索
可在模块:Hydrogina/sandbox/NameInText/doc创建此模块的帮助文档
p={}
publicframe=nil
function getnametable(str)
wordtable = {}
for word in string.gmatch(str, '%[name=".-".-%]') do
n=wordtable[word]
if(n==nil)then
wordtable[word]=1
else
wordtable[word]=n+1
end
end
nametable = {}
for word, n in pairs(wordtable) do
name=string.sub(word, 8 ,-3)
nametable[name]=n
--print(name,n)
end
return nametable
end
function pntnametable(nametable)
rtn=""
for name, n in pairs(nametable) do
--print(name,n)
rtn=rtn..name..","
end
return rtn
end
function p.get(frame)
local args = (frame == mw.getCurrentFrame() and frame.args) or frame
local rtn=""
publicframe=frame
s=args[1]
if(args["s"])then
s=args["s"]
end
s=mw.text.decode(s)
nametable=getnametable(s)
rtn=pntnametable(nametable)
return rtn
end
return p