https://en.wikipedia.org/w/index.php?action=history&feed=atom&title=Module%3ASortName%2Fsandbox Module:SortName/sandbox - Revision history 2025-05-30T19:32:25Z Revision history for this page on the wiki MediaWiki 1.45.0-wmf.3 https://en.wikipedia.org/w/index.php?title=Module:SortName/sandbox&diff=1149259336&oldid=prev Lemondoge: Slight simplification (else if to elseif) 2023-04-11T03:31:17Z <p>Slight simplification (else if to elseif)</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 03:31, 11 April 2023</td> </tr><tr> <td colspan="2" class="diff-lineno">Line 33:</td> <td colspan="2" class="diff-lineno">Line 33:</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 romannumeral == -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 romannumeral == -1 then</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> pagetitle = text1 .. ', ' .. text2</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> pagetitle = text1 .. ', ' .. text2</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker"><a class="mw-diff-movedpara-right" title="Paragraph was moved. Click to jump to old location." href="#movedpara_4_1_lhs">&#x26AB;</a></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><a name="movedpara_1_0_rhs"></a> <ins style="font-weight: bold; text-decoration: none;">elseif</ins> string.find( text2, ' ' ) <ins style="font-weight: bold; text-decoration: none;">==</ins> <ins style="font-weight: bold; text-decoration: none;">nil</ins> <ins style="font-weight: bold; text-decoration: none;">then</ins></div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker"><a class="mw-diff-movedpara-right" title="Paragraph was moved. Click to jump to old location." href="#movedpara_4_2_lhs">&#x26AB;</a></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><a name="movedpara_1_1_rhs"></a> pagetitle = <ins style="font-weight: bold; text-decoration: none;">text2</ins> .. ' ' .. romannumeral</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> else</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> else</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> <del style="font-weight: bold; text-decoration: none;">if</del> string.find( text2, ' ' ) <del style="font-weight: bold; text-decoration: none;">==</del> <del style="font-weight: bold; text-decoration: none;">nil</del> <del style="font-weight: bold; text-decoration: none;">then</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> <ins style="font-weight: bold; text-decoration: none;">text1 = string.sub( text2,</ins> string.find( text2, ' <ins style="font-weight: bold; text-decoration: none;">[^ ]*$</ins>' ) <ins style="font-weight: bold; text-decoration: none;">+</ins> <ins style="font-weight: bold; text-decoration: none;">1,</ins> <ins style="font-weight: bold; text-decoration: none;">#text2 )</ins></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> <del style="font-weight: bold; text-decoration: none;">pagetitle</del> <del style="font-weight: bold; text-decoration: none;">=</del> text2<del style="font-weight: bold; text-decoration: none;"> ..</del> ' ' <del style="font-weight: bold; text-decoration: none;">..</del> <del style="font-weight: bold; text-decoration: none;">romannumeral</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> <ins style="font-weight: bold; text-decoration: none;">text2</ins> <ins style="font-weight: bold; text-decoration: none;">=</ins> <ins style="font-weight: bold; text-decoration: none;">string.sub(</ins> <ins style="font-weight: bold; text-decoration: none;">text2,</ins> <ins style="font-weight: bold; text-decoration: none;">0,</ins> <ins style="font-weight: bold; text-decoration: none;">string.find(</ins> text2<ins style="font-weight: bold; text-decoration: none;">,</ins> ' <ins style="font-weight: bold; text-decoration: none;">[^ ]*$</ins>' <ins style="font-weight: bold; text-decoration: none;">) - 1</ins> <ins style="font-weight: bold; text-decoration: none;">)</ins></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> <del style="font-weight: bold; text-decoration: none;">else</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> <ins style="font-weight: bold; text-decoration: none;">pagetitle = text1 .. ' ' .. romannumeral .. ', ' .. text2</ins></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> text1 = string.sub( text2, string.find( text2, ' [^ ]*$' ) + 1, #text2 )</div></td> <td colspan="2" class="diff-empty diff-side-added"></td> </tr> <tr> <td class="diff-marker"><a class="mw-diff-movedpara-left" title="Paragraph was moved. Click to jump to new location." href="#movedpara_1_0_rhs">&#x26AB;</a></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><a name="movedpara_4_1_lhs"></a> <del style="font-weight: bold; text-decoration: none;"> text2 = string.sub( text2, 0,</del> string.find( text2, ' <del style="font-weight: bold; text-decoration: none;">[^ ]*$</del>' ) <del style="font-weight: bold; text-decoration: none;">-</del> <del style="font-weight: bold; text-decoration: none;">1</del> <del style="font-weight: bold; text-decoration: none;">)</del></div></td> <td colspan="2" class="diff-empty diff-side-added"></td> </tr> <tr> <td class="diff-marker"><a class="mw-diff-movedpara-left" title="Paragraph was moved. Click to jump to new location." href="#movedpara_1_1_rhs">&#x26AB;</a></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><a name="movedpara_4_2_lhs"></a><del style="font-weight: bold; text-decoration: none;"> </del> pagetitle = <del style="font-weight: bold; text-decoration: none;">text1</del> .. ' ' .. romannumeral<del style="font-weight: bold; text-decoration: none;"> .. ', ' .. text2</del></div></td> <td colspan="2" class="diff-empty diff-side-added"></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> end</div></td> <td colspan="2" class="diff-empty diff-side-added"></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;"><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> </table> Lemondoge https://en.wikipedia.org/w/index.php?title=Module:SortName/sandbox&diff=1149259218&oldid=prev Lemondoge: Create sandbox version of Module:SortName 2023-04-11T03:30:09Z <p>Create sandbox version of <a href="/wiki/Module:SortName" title="Module:SortName">Module:SortName</a></p> <p><b>New page</b></p><div>local p = {}<br /> <br /> function p.sortname(frame)<br /> local currentpage = mw.title.getCurrentTitle()<br /> local pagetitle = frame.args[1] or currentpage.text<br /> local langvar = mw.language.getContentLanguage()<br /> local text1 = &#039;&#039;<br /> local text2 = &#039;&#039;<br /> local parts = { &#039;de&#039;,&#039;De&#039;,&#039;von&#039;,&#039;Von&#039;,&#039;du&#039;,&#039;Du&#039;,&#039;del&#039;,&#039;Del&#039;,&#039;zu&#039;,&#039;Zu&#039;,&#039;di&#039;,&#039;Di&#039;,&#039;van&#039;,&#039;Van&#039;,&#039;na&#039;,&#039;Na&#039;,&#039;le&#039;,&#039;Le&#039;,&#039;de\&#039;&#039;,&#039;De\&#039;&#039; }<br /> local partmatch = false<br /> if string.find( pagetitle, &#039; &#039; ) ~= nil then<br /> pagetitle = string.gsub( string.gsub( string.gsub( pagetitle, &#039;%b()&#039;, &#039;&#039; ), &#039; +&#039;, &#039; &#039;), &#039; $&#039;, &#039;&#039; )<br /> if string.find( pagetitle, &#039;^List of &#039; ) ~= nil then<br /> pagetitle = langvar:ucfirst( string.gsub( pagetitle, &#039;^List of &#039;, &#039;&#039;, 1 ) )<br /> elseif string.find( pagetitle, &#039;^The &#039; ) ~= nil then<br /> pagetitle = string.gsub( pagetitle, &#039;^The &#039;, &#039;&#039; ) .. &#039;, The&#039;<br /> else<br /> pagetitle = string.gsub( pagetitle, &#039;,.*$&#039;, &#039;&#039; )<br /> pagetitle = string.gsub( pagetitle, &#039; of .*$&#039;, &#039;&#039; )<br /> for i in ipairs( parts ) do<br /> if string.find( pagetitle, &#039; &#039; .. parts[i] .. &#039; &#039; ) ~= nil then<br /> text1 = string.sub( pagetitle, string.find( pagetitle, &#039; &#039; .. parts[i] .. &#039; &#039; ) + 1, #pagetitle )<br /> text2 = string.sub( pagetitle, 0, string.find( pagetitle, &#039; &#039; .. parts[i] .. &#039; &#039; ) - 1 )<br /> pagetitle = text1 .. &#039;, &#039; .. text2<br /> partmatch = true<br /> break<br /> end<br /> end<br /> if not partmatch and string.find( pagetitle, &#039; &#039; ) ~= nil then<br /> text1 = string.sub( pagetitle, string.find( pagetitle, &#039; [^ ]*$&#039; ) + 1, #pagetitle )<br /> text2 = string.sub( pagetitle, 0, string.find( pagetitle, &#039; [^ ]*$&#039; ) - 1 )<br /> local romannumeral = roman_to_numeral(text1)<br /> if romannumeral == -1 then<br /> pagetitle = text1 .. &#039;, &#039; .. text2<br /> else<br /> if string.find( text2, &#039; &#039; ) == nil then<br /> pagetitle = text2 .. &#039; &#039; .. romannumeral<br /> else<br /> text1 = string.sub( text2, string.find( text2, &#039; [^ ]*$&#039; ) + 1, #text2 )<br /> text2 = string.sub( text2, 0, string.find( text2, &#039; [^ ]*$&#039; ) - 1 )<br /> pagetitle = text1 .. &#039; &#039; .. romannumeral .. &#039;, &#039; .. text2<br /> end<br /> end<br /> end<br /> end<br /> end<br /> return pagetitle<br /> end<br /> <br /> -- the following table and roman_to_numeral function came from Module:ConvertNumeric, created by User:Dcoetzee<br /> roman_numerals = {<br /> I = 1,<br /> V = 5,<br /> X = 10,<br /> L = 50,<br /> C = 100,<br /> D = 500,<br /> M = 1000<br /> }<br /> <br /> -- Converts a given valid roman numeral (and some invalid roman numerals) to a number. Returns -1, errorstring on error<br /> function roman_to_numeral(roman)<br /> if type(roman) ~= &quot;string&quot; then return -1, &quot;roman numeral not a string&quot; end<br /> local rev = roman:reverse()<br /> local raising = true<br /> local last = 0<br /> local result = 0<br /> for i = 1, #rev do<br /> local c = rev:sub(i, i)<br /> local next = roman_numerals[c]<br /> if next == nil then return -1, &quot;roman numeral contains illegal character &quot; .. c end<br /> if next &gt; last then<br /> result = result + next<br /> raising = true<br /> elseif next &lt; last then<br /> result = result - next<br /> raising = false<br /> elseif raising then<br /> result = result + next<br /> else<br /> result = result - next<br /> end<br /> last = next<br /> end<br /> return result<br /> end<br /> <br /> return p</div> Lemondoge