https://en.wikipedia.org/w/index.php?action=history&feed=atom&title=Module%3AConvertIB Module:ConvertIB - Revision history 2025-05-29T07:58:10Z Revision history for this page on the wiki MediaWiki 1.45.0-wmf.2 https://en.wikipedia.org/w/index.php?title=Module:ConvertIB&diff=1231500548&oldid=prev Pppery: Changed protection settings for "Module:ConvertIB": High-risk template or module ([Edit=Require template editor access] (indefinite) [Move=Require template editor access] (indefinite)) 2024-06-28T16:46:56Z <p>Changed protection settings for &quot;<a href="/wiki/Module:ConvertIB" title="Module:ConvertIB">Module:ConvertIB</a>&quot;: <a href="/wiki/Wikipedia:High-risk_templates" title="Wikipedia:High-risk templates">High-risk template or module</a> ([Edit=Require template editor access] (indefinite) [Move=Require template editor access] (indefinite))</p> <table style="background-color: #fff; color: #202122;" data-mw="interface"> <tr class="diff-title" lang="en"> <td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">← Previous revision</td> <td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 16:46, 28 June 2024</td> </tr><tr><td colspan="2" class="diff-notice" lang="en"><div class="mw-diff-empty">(No difference)</div> </td></tr></table> Pppery https://en.wikipedia.org/w/index.php?title=Module:ConvertIB&diff=1230436298&oldid=prev MusikBot II: Protected "Module:ConvertIB": High-risk template or module: 4766 transclusions (more info) ([Edit=Require extended confirmed access] (indefinite) [Move=Require extended confirmed access] (indefinite)) 2024-06-22T18:00:35Z <p>Protected &quot;<a href="/wiki/Module:ConvertIB" title="Module:ConvertIB">Module:ConvertIB</a>&quot;: <a href="/wiki/Wikipedia:High-risk_templates" title="Wikipedia:High-risk templates">High-risk template or module</a>: 4766 transclusions (<a href="/wiki/User:MusikBot_II/TemplateProtector" title="User:MusikBot II/TemplateProtector">more info</a>) ([Edit=Require extended confirmed access] (indefinite) [Move=Require extended confirmed access] (indefinite))</p> <table style="background-color: #fff; color: #202122;" data-mw="interface"> <tr class="diff-title" lang="en"> <td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">← Previous revision</td> <td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 18:00, 22 June 2024</td> </tr><tr><td colspan="2" class="diff-notice" lang="en"><div class="mw-diff-empty">(No difference)</div> </td></tr></table> MusikBot II https://en.wikipedia.org/w/index.php?title=Module:ConvertIB&diff=1230422161&oldid=prev Hike395: add early bail out, if there are no values at all 2024-06-22T16:33:36Z <p>add early bail out, if there are no values at all</p> <table style="background-color: #fff; color: #202122;" data-mw="interface"> <col class="diff-marker" /> <col class="diff-content" /> <col class="diff-marker" /> <col class="diff-content" /> <tr class="diff-title" lang="en"> <td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Previous revision</td> <td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 16:33, 22 June 2024</td> </tr><tr> <td colspan="2" class="diff-lineno">Line 19:</td> <td colspan="2" class="diff-lineno">Line 19:</td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>-- units: list of units (str)</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>-- units: list of units (str)</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>-- value: if there is a last numeric value unpaired with a unit, it becomes the precision</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>-- value: if there is a last numeric value unpaired with a unit, it becomes the precision</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>-- anyValue: whether there is a non-false value in the values list</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>local function parseValuesUnits(args)</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>local function parseValuesUnits(args)</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> local values = {}</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> local values = {}</div></td> </tr> <tr> <td colspan="2" class="diff-lineno">Line 24:</td> <td colspan="2" class="diff-lineno">Line 25:</td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> local indx = 1</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> local indx = 1</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> local value = nil</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> local value = nil</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> local anyValue = false</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- loop through numeric arguments in pairs</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- loop through numeric arguments in pairs</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> while args[indx] or args[indx+1] do</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> while args[indx] or args[indx+1] do</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> value = args[indx]</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> value = args[indx]</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> anyValue = anyValue or value</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- if there is a unit, save in output lists</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- if there is a unit, save in output lists</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> if args[indx+1] then</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> if args[indx+1] then</div></td> </tr> <tr> <td colspan="2" class="diff-lineno">Line 35:</td> <td colspan="2" class="diff-lineno">Line 38:</td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> indx = indx+2</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> indx = indx+2</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> end</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> end</div></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> return values, units, value</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> return values, units, value<ins style="font-weight: bold; text-decoration: none;">, anyValue</ins></div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>end</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>end</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td colspan="2" class="diff-lineno">Line 115:</td> <td colspan="2" class="diff-lineno">Line 118:</td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>function p._convert(args)</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>function p._convert(args)</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- find all values and units in numeric args (and the precision, if it exists)</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- find all values and units in numeric args (and the precision, if it exists)</div></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> local values, units, precision = parseValuesUnits(args)</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> local values, units, precision<ins style="font-weight: bold; text-decoration: none;">, anyValue</ins> = parseValuesUnits(args)</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> -- bail if no values at all</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> if not anyValue then</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> return nil</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> end</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- rewrite values and units if multiple units are found</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- rewrite values and units if multiple units are found</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> values, units = parseMultiples(values, units)</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> values, units = parseMultiples(values, units)</div></td> </tr> </table> Hike395 https://en.wikipedia.org/w/index.php?title=Module:ConvertIB&diff=1230415787&oldid=prev Hike395: don't filter values for numeric strings: pass to {{convert}} directly 2024-06-22T15:52:05Z <p>don&#039;t filter values for numeric strings: pass to {{convert}} directly</p> <table style="background-color: #fff; color: #202122;" data-mw="interface"> <col class="diff-marker" /> <col class="diff-content" /> <col class="diff-marker" /> <col class="diff-content" /> <tr class="diff-title" lang="en"> <td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Previous revision</td> <td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 15:52, 22 June 2024</td> </tr><tr> <td colspan="2" class="diff-lineno">Line 26:</td> <td colspan="2" class="diff-lineno">Line 26:</td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- loop through numeric arguments in pairs</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- loop through numeric arguments in pairs</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> while args[indx] or args[indx+1] do</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> while args[indx] or args[indx+1] do</div></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> value = <del style="font-weight: bold; text-decoration: none;">tonumber(</del>args[indx]<del style="font-weight: bold; text-decoration: none;">)</del></div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> value = args[indx]</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- if there is a unit, save in output lists</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- if there is a unit, save in output lists</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> if args[indx+1] then</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> if args[indx+1] then</div></td> </tr> </table> Hike395 https://en.wikipedia.org/w/index.php?title=Module:ConvertIB&diff=1229850425&oldid=prev Hike395: rewrite convinfobox in Lua 2024-06-19T01:26:37Z <p>rewrite convinfobox in Lua</p> <p><b>New page</b></p><div>require(&#039;strict&#039;)<br /> local p = {}<br /> local getArgs = require(&#039;Module:Arguments&#039;).getArgs<br /> <br /> -- Units accepted by {{convert}} that come in groups (e.g., &quot;5 ft 6 in&quot;)<br /> local multiple = <br /> {&#039;mich&#039;, &#039;michlk&#039;, &#039;michainlk&#039;, &#039;miyd&#039;, &#039;miydftin&#039;, &#039;mift&#039;, &#039;ydftin&#039;, &#039;ydft&#039;,<br /> &#039;ftin&#039;, &#039;footin&#039;, &#039;handin&#039;, &#039;lboz&#039;, &#039;stlb&#039;, &#039;stlboz&#039;, &#039;stlb&#039;}<br /> <br /> -- Convert unit list to hash<br /> local mult_table = {}<br /> for _, v in ipairs(multiple) do<br /> mult_table[v] = true<br /> end<br /> <br /> -- Function to pull out values and units from numeric args<br /> -- Returns:<br /> -- values: list of numeric values, or &quot;false&quot; if no numeric argument is given<br /> -- units: list of units (str)<br /> -- value: if there is a last numeric value unpaired with a unit, it becomes the precision<br /> local function parseValuesUnits(args)<br /> local values = {}<br /> local units = {}<br /> local indx = 1<br /> local value = nil<br /> -- loop through numeric arguments in pairs<br /> while args[indx] or args[indx+1] do<br /> value = tonumber(args[indx])<br /> -- if there is a unit, save in output lists<br /> if args[indx+1] then<br /> table.insert(values, value or false)<br /> table.insert(units, args[indx+1])<br /> value = nil<br /> end<br /> indx = indx+2<br /> end<br /> return values, units, value<br /> end<br /> <br /> -- Function to identify multiple units and rewrite them as new input or output groups<br /> -- Args:<br /> -- values, units: numeric values and units, as lists with same length<br /> -- Returns:<br /> -- newValues, newUnits: same lists rewritten<br /> local function parseMultiples(values, units)<br /> local newValues = {}<br /> local newUnits = {}<br /> local i = 1<br /> -- we will search for multiples with up to 4 entries (depending on length)<br /> local maxMultiple = math.min(4,#units-1)<br /> local valueFound = false -- flag to suppress second (and later) input values<br /> --- Hack for handling &quot;stone&quot;: check if only value supplied is &quot;lb&quot;<br /> local onlyPounds = true<br /> for i = 1, #units do<br /> if values[i] and units[i] ~= &#039;lb&#039; then<br /> onlyPounds = false<br /> break<br /> end<br /> end<br /> -- sweep through units<br /> while i &lt;= #units do<br /> -- determine index of last possible unit that could contain a multiple<br /> local last_unit = math.min(i+maxMultiple-1,#units)<br /> local multipleFound = false<br /> -- try from longest multiple down to double multiple (prefer longest ones)<br /> for j = last_unit, i+1, -1 do<br /> local key = table.concat({unpack(units,i,j)}, &#039;&#039;)<br /> if mult_table[key] then<br /> -- we found a multiple unit<br /> multipleFound = true<br /> -- Hack for &quot;stone&quot;: add either &#039;lb&#039; or multiple unit string to output units<br /> -- depending on whether &#039;lb&#039; was the only unit string with a value<br /> if mw.ustring.sub(key,1,2) == &#039;st&#039; then<br /> table.insert(newValues, false)<br /> table.insert(newUnits, onlyPounds and key or &#039;lb&#039;)<br /> end<br /> -- if there are any value in the span of the multiple,<br /> -- then the multiple is an input<br /> -- assume all missing values after the first are zero<br /> local firstValueFound = false<br /> for k = i, j do<br /> firstValueFound = not valueFound and (firstValueFound or values[k])<br /> if firstValueFound then<br /> table.insert(newValues, values[k] or 0)<br /> table.insert(newUnits, units[k])<br /> end<br /> end<br /> valueFound = valueFound or firstValueFound<br /> -- if no values in the span of the multiple,<br /> -- then the multiple is an output. Insert combined string as output unit<br /> if not firstValueFound then<br /> table.insert(newValues, false)<br /> table.insert(newUnits, key)<br /> end<br /> i = j+1<br /> break<br /> end<br /> end<br /> --- If no multiple unit was found, insert value[i] and unit[i] into rewritten lists<br /> if not multipleFound then<br /> if valueFound then<br /> table.insert(newValues, false) -- skip writing value if it is a duplicate<br /> else<br /> table.insert(newValues,values[i])<br /> valueFound = values[i]<br /> end<br /> table.insert(newUnits, units[i])<br /> i = i+1<br /> end<br /> end<br /> return newValues, newUnits <br /> end<br /> <br /> -- Implement {{convinfobox}}<br /> function p._convert(args)<br /> -- find all values and units in numeric args (and the precision, if it exists)<br /> local values, units, precision = parseValuesUnits(args)<br /> -- rewrite values and units if multiple units are found<br /> values, units = parseMultiples(values, units)<br /> -- sort input and outputs into different buckets<br /> local input_values = {}<br /> local input_units = {}<br /> local output_units = {}<br /> for i = 1, #units do<br /> if values[i] then<br /> table.insert(input_values, values[i])<br /> table.insert(input_units, units[i])<br /> else<br /> table.insert(output_units, units[i])<br /> end<br /> end<br /> -- bail if nothing to convert<br /> if #input_values == 0 or #output_units == 0 then<br /> return nil<br /> end<br /> -- assemble argument list to {{convert}}<br /> local innerArgs = {}<br /> -- First, pass all input unit(s)<br /> for i, v in ipairs(input_values) do<br /> table.insert(innerArgs,v)<br /> table.insert(innerArgs,input_units[i])<br /> end<br /> -- Then the output unit(s) [concatenated as single argument]<br /> table.insert(innerArgs,table.concat(output_units,&quot;+&quot;))<br /> if precision then<br /> table.insert(innerArgs,precision) -- last non-nil value contains precision<br /> end<br /> -- now handle all non-numeric arguments, passing to {{convert}}<br /> innerArgs.abbr = &#039;on&#039; -- abbr=on by default<br /> for k, v in pairs(args) do<br /> if not tonumber(k) then<br /> innerArgs[k] = v<br /> end<br /> end<br /> -- Call {{convert}} with innerArgs<br /> local frame = mw.getCurrentFrame()<br /> return frame:expandTemplate{title=&#039;Convert&#039;, args=innerArgs}<br /> end<br /> <br /> function p.convert(frame)<br /> local args = getArgs(frame)<br /> return p._convert(args) or &quot;&quot;<br /> end<br /> <br /> return p</div> Hike395