https://de.wikipedia.org/w/index.php?action=history&feed=atom&title=Modul%3ACheck_for_unknown_parameters Modul:Check for unknown parameters - Versionsgeschichte 2025-04-21T12:43:36Z Versionsgeschichte dieser Seite in Wikipedia MediaWiki 1.44.0-wmf.25 https://de.wikipedia.org/w/index.php?title=Modul:Check_for_unknown_parameters&diff=187111783&oldid=prev Du khách Hà Nội: Übernommen von :en:Module:Check for unknown parameters 2019-03-31T19:48:48Z <p>Übernommen von <a href="https://en.wikipedia.org/wiki/Module:Check_for_unknown_parameters" class="extiw" title="en:Module:Check for unknown parameters">en:Module:Check for unknown parameters</a></p> <p><b>Neue Seite</b></p><div>-- This module may be used to compare the arguments passed to the parent<br /> -- with a list of arguments, returning a specified result if an argument is<br /> -- not on the list<br /> local p = {}<br /> <br /> local function trim(s)<br /> return s:match(&#039;^%s*(.-)%s*$&#039;)<br /> end<br /> <br /> local function isnotempty(s)<br /> return s and s:match(&#039;%S&#039;)<br /> end<br /> <br /> local function clean(text)<br /> -- Return text cleaned for display and truncated if too long.<br /> -- Strip markers are replaced with dummy text representing the original wikitext.<br /> local pos, truncated<br /> local function truncate(text)<br /> if truncated then<br /> return &#039;&#039;<br /> end<br /> if mw.ustring.len(text) &gt; 25 then<br /> truncated = true<br /> text = mw.ustring.sub(text, 1, 25) .. &#039;...&#039;<br /> end<br /> return mw.text.nowiki(text)<br /> end<br /> local parts = {}<br /> for before, tag, remainder in text:gmatch(&#039;([^\127]*)\127[^\127]*%-(%l+)%-[^\127]*\127()&#039;) do<br /> pos = remainder<br /> table.insert(parts, truncate(before) .. &#039;&amp;lt;&#039; .. tag .. &#039;&amp;gt;...&amp;lt;/&#039; .. tag .. &#039;&amp;gt;&#039;)<br /> end<br /> table.insert(parts, truncate(text:sub(pos or 1)))<br /> return table.concat(parts)<br /> end<br /> <br /> function p.check (frame)<br /> local args = frame.args<br /> local pargs = frame:getParent().args<br /> local ignoreblank = isnotempty(args[&#039;ignoreblank&#039;])<br /> local showblankpos = isnotempty(args[&#039;showblankpositional&#039;])<br /> local knownargs = {}<br /> local unknown = args[&#039;unknown&#039;] or &#039;Found _VALUE_, &#039;<br /> local preview = args[&#039;preview&#039;]<br /> <br /> local values = {}<br /> local res = {}<br /> local regexps = {}<br /> <br /> -- create the list of known args, regular expressions, and the return string<br /> for k, v in pairs(args) do<br /> if type(k) == &#039;number&#039; then<br /> v = trim(v)<br /> knownargs[v] = 1<br /> elseif k:find(&#039;^regexp[1-9][0-9]*$&#039;) then<br /> table.insert(regexps, &#039;^&#039; .. v .. &#039;$&#039;)<br /> end<br /> end<br /> if isnotempty(preview) then<br /> preview = &#039;&lt;div class=&quot;hatnote&quot; style=&quot;color:red&quot;&gt;&lt;strong&gt;Warning:&lt;/strong&gt; &#039; .. preview .. &#039; (this message is shown only in preview).&lt;/div&gt;&#039;<br /> elseif preview == nil then<br /> preview = unknown<br /> end<br /> <br /> -- loop over the parent args, and make sure they are on the list<br /> for k, v in pairs(pargs) do<br /> if type(k) == &#039;string&#039; and knownargs[k] == nil then<br /> local knownflag = false<br /> for _, regexp in ipairs(regexps) do<br /> if mw.ustring.match(k, regexp) then<br /> knownflag = true<br /> break<br /> end<br /> end<br /> if not knownflag and ( not ignoreblank or isnotempty(v) ) then<br /> table.insert(values, clean(k))<br /> end<br /> elseif type(k) == &#039;number&#039; and<br /> knownargs[tostring(k)] == nil and<br /> ( showblankpos or isnotempty(v) )<br /> then<br /> table.insert(values, k .. &#039; = &#039; .. clean(v))<br /> end<br /> end<br /> <br /> -- add results to the output tables<br /> if #values &gt; 0 then<br /> if frame:preprocess( &quot;{{REVISIONID}}&quot; ) == &quot;&quot; then<br /> unknown = preview<br /> end<br /> for _, v in pairs(values) do<br /> if v == &#039;&#039; then<br /> -- Fix odd bug for | = which gets stripped to the empty string and<br /> -- breaks category links<br /> v = &#039; &#039;<br /> end<br /> -- avoid error with v = &#039;example%2&#039; (&quot;invalid capture index&quot;)<br /> local r = unknown:gsub(&#039;_VALUE_&#039;, {_VALUE_ = v})<br /> table.insert(res, r)<br /> end<br /> end<br /> <br /> return table.concat(res)<br /> end<br /> <br /> return p</div> Du khách Hà Nội