Movatterモバイル変換


[0]ホーム

URL:


Jump to content
Wikipedia
Lava

Module:Check for unknown parameters

Kusuka e Wikipedia

Documentation for this module may be created atModule:Check for unknown parameters/doc

-- This module may be used to compare the arguments passed to the parent-- with a list of arguments, returning a specified result if an argument is-- not on the listlocalp={}localfunctiontrim(s)returns:match('^%s*(.-)%s*$')endlocalfunctionisnotempty(s)returnsandtrim(s)~=''endfunctionp.check(frame)localargs=frame.argslocalpargs=frame:getParent().argslocalignoreblank=isnotempty(frame.args['ignoreblank'])localcheckpos=isnotempty(frame.args['checkpositional'])localknownargs={}localunknown=frame.args['unknown']or'Found _VALUE_, 'localpreview=frame.args['preview']orunknownlocalres={}localregexps={}localcomments={}localcommentstr=''localispreview=frame:preprocess("{{REVISIONID}}")==""and1or0-- create the list of known args, regular expressions, and the return stringfork,vinpairs(args)doiftype(k)=='number'thenv=trim(v)knownargs[v]=1elseifk:find('^regexp[1-9][0-9]*$')thentable.insert(regexps,'^'..v..'$')endendifisnotempty(frame.args['preview'])thenpreview='<div><strong>Warning:</strong> '..frame.args['preview']..' (this message is shown only in preview).</div>'elseifframe.args['preview']thenpreview=frame.args['preview']elsepreview=unknownendifispreview==1thenunknown=previewend-- adds one result to the output tableslocalfunctionaddresult(k)ifk==''then-- Fix odd bug for | = which gets stripped to the empty string and-- breaks category linksk=' 'endlocalr=unknown:gsub('_VALUE_',k)table.insert(res,r)table.insert(comments,'"'..k..'"')end-- loop over the parent args, and make sure they are on the listfork,vinpairs(pargs)doiftype(k)=='string'andknownargs[k]==nilthenlocalknownflag=falsefori,regexpinipairs(regexps)doifmw.ustring.match(k,regexp)thenknownflag=truebreakendendifnotknownflagand(notignoreblankorisnotempty(v))thenk=mw.ustring.gsub(k,'[^%w\-_ ]','?')addresult(k)endelseifcheckposandtype(k)=='number'andknownargs[tostring(k)]==niland(notignoreblankorisnotempty(v))thenaddresult(k)endendif#comments>0thencommentstr='<!-- Module:Check for unknown parameters results: '..table.concat(comments,', ')..'-->'endreturntable.concat(res)..commentstrendreturnp
ku suka e "https://ts.wikipedia.org/w/index.php?title=Module:Check_for_unknown_parameters&oldid=31831"

[8]ページ先頭

©2009-2025 Movatter.jp