Movatterモバイル変換


[0]ホーム

URL:


Fara í innihald
WikipediaFrjálsa alfræðiritið
Leit

Module:Check for unknown parameters

Úr Wikipediu, frjálsa alfræðiritinu

Þessi skrifta er til að athuga eftir gildum sem eru gefin upp á síðum en ekki stutt af sniðinu. Skriftan er bara notuð í sniðum, ekki öðrum síðum.

{{#invoke:Check for unknown parameters|check| ignoreblank= | showblankpositional= | unknown= | preview =}}

-- 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)returnsands:match('%S')endlocalfunctionclean(text)-- Return text cleaned for display and truncated if too long.-- Strip markers are replaced with dummy text representing the original wikitext.localpos,truncatedlocalfunctiontruncate(text)iftruncatedthenreturn''endifmw.ustring.len(text)>25thentruncated=truetext=mw.ustring.sub(text,1,25)..'...'endreturnmw.text.nowiki(text)endlocalparts={}forbefore,tag,remainderintext:gmatch('([^\127]*)\127[^\127]*%-(%l+)%-[^\127]*\127()')dopos=remaindertable.insert(parts,truncate(before)..'&lt;'..tag..'&gt;...&lt;/'..tag..'&gt;')endtable.insert(parts,truncate(text:sub(posor1)))returntable.concat(parts)endfunctionp.check(frame)localargs=frame.argslocalpargs=frame:getParent().argslocalignoreblank=isnotempty(args['ignoreblank'])localshowblankpos=isnotempty(args['showblankpositional'])localknownargs={}localunknown=args['unknown']or'Found _VALUE_, 'localpreview=args['preview']localvalues={}localres={}localregexps={}-- 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..'$')endend-- loop over the parent args, and make sure they are on the listfork,vinpairs(pargs)doiftype(k)=='string'andknownargs[k]==nilthenlocalknownflag=falsefor_,regexpinipairs(regexps)doifmw.ustring.match(k,regexp)thenknownflag=truebreakendendifnotknownflagand(notignoreblankorisnotempty(v))thentable.insert(values,clean(k))endelseiftype(k)=='number'andknownargs[tostring(k)]==niland(showblankposorisnotempty(v))thentable.insert(values,k..' = '..clean(v))endend-- add results to the output tablesif#values>0thenfor_,vinpairs(values)doifv==''then-- Fix odd bug for | = which gets stripped to the empty string and-- breaks category linksv=' 'end-- avoid error with v = 'example%2' ("invalid capture index")localr=unknown:gsub('_VALUE_',{_VALUE_=v})endendifisnotempty(preview)andrthenpreview=mw.addWarning('<div><strong>Warning:</strong> '..r..' (this message is shown only in preview).</div>')elseifpreview==nilthenpreview=unknownendlocaltemplatestyles=mw.getCurrentFrame():extensionTag{name='templatestyles',args={src="Module:Hatnote/styles.css"}}returntemplatestyles..table.concat(res)endreturnp
Sótt frá „https://is.wikipedia.org/w/index.php?title=Module:Check_for_unknown_parameters&oldid=1816359

[8]ページ先頭

©2009-2025 Movatter.jp