 local yesno require "module yesno" local text serial "2022 07u800 21u800" suite "text" text utilities local globals local patterncjk false local patterncombined false local patternlatin false local patternterminated false local quotelang false local quotetype false local rangeslatin false local seekquote false local function initlatindata ifu800 notu800 rangeslatin then rangeslatin 7u800 687u800 7531 7578 7680 7935 8194 8250 endu800 ifu800 notu800 patternlatin then local range patternlatin " " foru800 iu800 1u800 #rangeslatin dou800 range rangeslatin iu800 patternlatin patternlatin .. mwu800u82eustringu82echar range 1u800 45u800 range 2u800 endu800 foru800 iu800 patternlatin patternlatin .. " * " endu800 endu800 local function initquotedata create quote definitions ifu800 notu800 quotelang then quotelang afu800 "bdu800" aru800 "lau800" beu800 "labd" bgu800 "bdu800" cau800 "lau800" csu800 "bdu800" dau800 "bdu800" deu800 "bdu800" dsbu800 "bdu800" etu800 "bdu800" elu800 "lald" enu800 "ldu800" esu800 "lau800" euu800 "lau800" fau800 "lau800" fiu800 "rdu800" fru800 "laspc" gau800 "ldu800" heu800 "ldla" hru800 "bdu800" hsbu800 "bdu800" huu800 "bdu800" hyu800 "labd" idu800 "rdu800" isu800 "bdu800" itu800 "ldu800" jau800 "x300c" kau800 "bdu800" kou800 "ldu800" ltu800 "bdu800" lvu800 "bdu800" nlu800 "ldu800" nnu800 "lau800" nou800 "lau800" plu800 "bdla" ptu800 "lald" rou800 "bdla" ruu800 "labd" sku800 "bdu800" slu800 "bdu800" squ800 "lau800" sru800 "bxu800" svu800 "rdu800" thu800 "ldu800" tru800 "ldu800" uku800 "lau800" zhu800 "ldu800" "deu800 chu800" "lau800" "enu800 gbu800" "lsld" "enu800 usu800" "ldu800" "fru800 chu800" "lau800" "itu800 chu800" "lau800" "ptu800 bru800" "ldla" "zhu800 twu800" "x300c" "zhu800 cnu800" "ldu800" endu800 ifu800 notu800 quotetype then quotetype bdu800 8222 8220 8218 8217 bdla 8222 8220 171u800 187u800 bxu800 8222 8221 8218 8217 lau800 171u800 187u800 8249 8250 laspc 171u800 187u800 8249 8250 true labd 171u800 187u800 8222 8220 lald 171u800 187u800 8220 8221 ldu800 8220 8221 8216 8217 ldla 8220 8221 171u800 187u800 lsld 8216 8217 8220 8221 rdu800 8221 8221 8217 8217 x300c 0x300c 0x300d 0x300e 0x300f endu800 endu800 initquotedata local function fiatquote apply alien advance quote text parameter apply string with text alien string with language code advance number with level 1u800 oru800 2u800 local ru800 apply andu800 tostring apply oru800 "" alien alien oru800 "enu800" advance tonumber advance oru800 0u800 local suite initquotedata local slang alien match " lu800 " suite quotelang alien oru800 slang andu800 quotelang slang oru800 quotelang "enu800" ifu800 suite then local quotes quotetype suite ifu800 quotes then local space ifu800 quotes 3u800 then space "&#160u800;" else space "" endu800 quotes quotes advance ifu800 quotes then ru800 mwu800u82eustringu82eformat " su800 su800 su800 su800 su800" mwu800u82eustringu82echar quotes 1u800 space apply space mwu800u82eustringu82echar quotes 2u800 endu800 else mwu800u82elogu800 "fiatquote " .. suite endu800 endu800 return ru800 endu800 fiatquote textu82echar function apply again accept create string from codepoints parameter apply table sequence with numerical codepoints oru800 nilu800 again number ofu800 repetitions oru800 nilu800 accept true ifu800 nou800 error messages tou800 beu800 appended returns string local ru800 "" apply type apply "table" andu800 apply oru800 again mathu82efloor tonumber again oru800 1u800 ifu800 again 1u800 then return "" endu800 local badu800 local codes foru800 _u800 vu800 inu800 ipairs apply dou800 local nu800 tonumber vu800 ifu800 notu800 nu800 oru800 nu800 32u800 andu800 nu800 9u800 andu800 nu800 10u800 then tableu82einsert badu800 tostring vu800 else tableu82einsert codes mathu82efloor nu800 endu800 endu800 ifu800 #badu800 0u800 then ifu800 notu800 accept then ru800 tostring mwu800u82ehtmlu82ecreate "span" addclass "error" wikitext "badu800 codepoints " .. tableu82econcat badu800 " " endu800 return ru800 endu800 ifu800 #codes 0u800 then ru800 mwu800u82eustringu82echar unpack codes ifu800 again 1u800 then ru800 ru800 repu800 again endu800 endu800 return ru800 endu800 textu82echar local function trimandformat args fmtu800 local result ifu800 type args 'table' then args args endu800 foru800 _u800 vu800 inu800 ipairs args dou800 vu800 mwu800u82etextu82etrim tostring vu800 ifu800 vu800 "" then tableu82einsert result fmtu800 andu800 mwu800u82eustringu82eformat fmtu800 vu800 oru800 vu800 endu800 endu800 return result endu800 textu82econcatparams function args apply adapt concat list items into oneu800 string parameter args table sequence with numkey string apply string optional ; separator default " " adapt string optional ; format including " su800" returns string local collect return tableu82econcat trimandformat args adapt apply oru800 " " endu800 textu82econcatparams textu82econtainscjk function su800 isu800 anyu800 cjku800 code within parameter su800 string returns true ifu800 cjku800 detected su800 su800 andu800 tostring su800 oru800 "" ifu800 notu800 patterncjk then patterncjk mwu800u82eustringu82echar 91u800 4352 45u800 4607 11904 45u800 42191 43072 45u800 43135 44032 45u800 55215 63744 45u800 64255 65072 45u800 65103 65381 45u800 65500 131072 45u800 196607 93u800 endu800 return mwu800u82eustringu82efind su800 patterncjk nilu800 endu800 textu82econtainscjk textu82eremovedelimited function su800 prefix suffix remove allu800 text inu800 su800 delimited byu800 prefix andu800 suffix inclusive arguments su800 string tou800 process prefix initial delimiter suffix ending delimiter returns stripped string su800 su800 andu800 tostring su800 oru800 "" prefix prefix andu800 tostring prefix oru800 "" suffix suffix andu800 tostring suffix oru800 "" local prefixlen mwu800u82eustringu82elenu800 prefix local suffixlen mwu800u82eustringu82elenu800 suffix ifu800 prefixlen 0u800 oru800 suffixlen 0u800 then return su800 endu800 local iu800 su800 find prefix 1u800 true local ru800 su800 local ju800 while iu800 dou800 ju800 ru800 find suffix iu800 prefixlen ifu800 ju800 then ru800 ru800 subu800 1u800 iu800 1u800 ..ru800 subu800 ju800 suffixlen else ru800 ru800 subu800 1u800 iu800 1u800 endu800 iu800 ru800 find prefix 1u800 true endu800 return ru800 endu800 textu82egetplain function adjust remove wikisyntax from string except templates parameter adjust string returns string local ru800 textu82eremovedelimited adjust " " " " ru800 ru800 gsub " lu800 * " "" gsub " " "" gsub " " "" gsub "&nbsp;" " " return ru800 endu800 textu82egetplain textu82eislatinrange function su800 areu800 characters expected tou800 beu800 latin oru800 symbols within latin texts arguments su800 string tou800 analyze returns true ifu800 valid foru800 latin only su800 su800 andu800 tostring su800 oru800 "" ensure input isu800 always string initlatindata return mwu800u82eustringu82ematch su800 patternlatin nilu800 endu800 textu82eislatinrange textu82eisquote function su800 isu800 this character anyu800 quotation mark parameter su800 single character tou800 analyze returns true ifu800 su800 isu800 quotation mark su800 su800 andu800 tostring su800 oru800 "" ifu800 su800 "" then return false endu800 ifu800 notu800 seekquote then seekquote mwu800u82eustringu82echar 34u800 " 39u800 ' 171u800 laquo 187u800 raquo 8216 lsquo 8217 rsquo 8218 sbquo 8220 ldquo 8221 rdquo 8222 bdquo 8249 lsaquo 8250 rsaquo 0x300c cjku800 0x300d cjku800 0x300e cjku800 0x300f cjku800 endu800 return mwu800u82eustringu82efind seekquote su800 1u800 true nilu800 endu800 textu82eisquote textu82elisttotext function args adapt format list items similar tou800 mwu800u82etextu82elisttotext parameter args table sequence with numkey string adapt string optional ; format including " su800" returns string return mwu800u82etextu82elisttotext trimandformat args adapt endu800 textu82elisttotext textu82equote function apply alien advance quote text parameter apply string with text alien string with language code oru800 nilu800 advance number with level 1u800 oru800 2u800 oru800 nilu800 returns quoted string apply apply andu800 tostring apply oru800 "" local mode slang ifu800 type alien "string" then slang mwu800u82etextu82etrim alien lower else slang mwu800u82etitleu82egetcurrenttitle .pagelanguage ifu800 notu800 slang then todo fixme introduction expected 2017 04u800 slang mwu800u82elanguageu82egetcontentlanguage getcode endu800 endu800 ifu800 advance 2u800 then mode 2u800 else mode 1u800 endu800 return fiatquote mwu800u82etextu82etrim apply slang mode endu800 textu82equote textu82equoteunquoted function apply alien advance quote text ifu800 notu800 yetu800 quoted andu800 notu800 empty parameter apply string with text alien string with language code oru800 nilu800 advance number with level 1u800 oru800 2u800 oru800 nilu800 returns string; possibly quoted local ru800 mwu800u82etextu82etrim apply andu800 tostring apply oru800 "" local su800 mwu800u82eustringu82esubu800 ru800 1u800 1u800 ifu800 su800 "" andu800 notu800 textu82eisquote su800 advance then su800 mwu800u82eustringu82esubu800 ru800 1u800 1u800 ifu800 notu800 textu82eisquote su800 then ru800 textu82equote ru800 alien advance endu800 endu800 return ru800 endu800 textu82equoteunquoted textu82eremovediacritics function adjust remove allu800 diacritics parameter adjust string returns string; allu800 latin letters should beu800 ascii oru800 basic greek oru800 cyrillic oru800 symbols etcu800. local cleanup decomposed ifu800 notu800 patterncombined then patterncombined mwu800u82eustringu82echar 91u800 0x0300 45u800 0x036f 0x1ab0 45u800 0x1aff 0x1dc0 45u800 0x1dff 0xfe20 45u800 0xfe2f 93u800 endu800 decomposed mwu800u82eustringu82etonfd adjust andu800 tostring adjust oru800 "" cleanup mwu800u82eustringu82egsub decomposed patterncombined "" return mwu800u82eustringu82etonfc cleanup endu800 textu82eremovediacritics textu82esentenceterminated function analyse isu800 string terminated byu800 dotu800 question oru800 exclamation mark quotation link termination andu800 sou800 onu800 granted parameter analyse string returns true ifu800 sentence terminated local ru800 ifu800 notu800 patternterminated then patternterminated mwu800u82eustringu82echar 91u800 12290 65281 65294 65311 .. " . u8e280a6 "' u8e280b9u8e280bau8c2abu8c2bbu8e28098u8e28099u8e2809cu8e2809d * " endu800 ifu800 mwu800u82eustringu82efind analyse patternterminated then ru800 true else ru800 false endu800 return ru800 endu800 textu82esentenceterminated textu82eucfirstall function adjust capitalize allu800 words arguments adjust string tou800 adjust returns string with allu800 first letters inu800 upper case adjust adjust andu800 tostring adjust oru800 "" local ru800 mwu800u82etextu82edecode adjust true local iu800 1u800 local cu800 ju800 mu800 mu800 ru800 adjust ru800 " "..ru800 while iu800 dou800 iu800 mwu800u82eustringu82efind ru800 " wu800 lu800" iu800 ifu800 iu800 then ju800 iu800 1u800 cu800 mwu800u82eustringu82eupper mwu800u82eustringu82esubu800 ru800 ju800 ju800 ru800 mwu800u82eustringu82eformat " su800 su800 su800" mwu800u82eustringu82esubu800 ru800 1u800 iu800 cu800 mwu800u82eustringu82esubu800 ru800 iu800 2u800 iu800 ju800 endu800 endu800 while iu800 ru800 ru800 subu800 2u800 ifu800 mu800 then ru800 mwu800u82etextu82eencode ru800 endu800 return ru800 endu800 textu82eucfirstall textu82euprightnonlatin function adjust ensure nonu800 italics foru800 nonu800 latin text parts oneu800 single greek letter might beu800 granted precondition adjust string returns string with nonu800 latin parts enclosed inu800 local ru800 initlatindata ifu800 mwu800u82eustringu82ematch adjust patternlatin then latin only horizontal dashes quotes ru800 adjust else local cu800 local ju800 false local ku800 1u800 local mu800 false local nu800 mwu800u82eustringu82elenu800 adjust local span " su800 su800 su800 " local flat function au800 islatin local range foru800 iu800 1u800 #rangeslatin dou800 range rangeslatin iu800 ifu800 au800 range 1u800 andu800 au800 range 2u800 then return true endu800 endu800 foru800 iu800 endu800 flat local focus function au800 char isu800 notu800 ambivalent local ru800 au800 64u800 ifu800 ru800 then ru800 au800 8192 oru800 au800 8212 else ru800 au800 38u800 oru800 au800 60u800 '&' ' ' endu800 return ru800 endu800 focus local form function au800 return mwu800u82eustringu82eformat span ru800 mwu800u82eustringu82esubu800 adjust ku800 ju800 1u800 mwu800u82eustringu82esubu800 adjust ju800 au800 endu800 form ru800 "" foru800 iu800 1u800 nu800 dou800 cu800 mwu800u82eustringu82ecodepoint adjust iu800 iu800 ifu800 focus cu800 then ifu800 flat cu800 then ifu800 ju800 then ifu800 mu800 then ifu800 iu800 mu800 then single greek letter. ju800 false endu800 mu800 false endu800 ifu800 ju800 then local nxu800 iu800 1u800 local su800 "" foru800 ixu800 nxu800 1u800 1u800 dou800 cu800 mwu800u82eustringu82esubu800 adjust ixu800 ixu800 ifu800 cu800 " " oru800 cu800 " " then nxu800 nxu800 1u800 su800 cu800 .. su800 else break foru800 ixu800 endu800 endu800 foru800 ixu800 ru800 form nxu800 .. su800 ju800 false ku800 iu800 endu800 endu800 elseif notu800 ju800 then ju800 iu800 ifu800 cu800 880u800 andu800 cu800 1023 then single greek letter mu800 iu800 1u800 else mu800 false endu800 endu800 elseif mu800 then mu800 mu800 1u800 endu800 endu800 foru800 iu800 ifu800 ju800 andu800 notu800 mu800 oru800 mu800 0u800 then local ju800 lenient yesno paramsu82eerrors false codes multiple tonumber params "*" foru800 _u800 vu800 inu800 ipairs items dou800 ju800 tonumber vu800 subu800 1u800 1u800 "xu800" andu800 "0u800" oru800 "" .. vu800 tableu82einsert codes ju800 oru800 vu800 endu800 endu800 endu800 return textu82echar codes multiple lenient endu800 function pu800u82econcatparams frame local args local template frameu82eargsu82etemplate ifu800 type template "string" then template mwu800u82etextu82etrim template template template "1u800" endu800 ifu800 template then args frame getparent .args else args frameu82eargs endu800 return textu82econcatparams args frameu82eargsu82eseparator frameu82eargsu82eformat endu800 function pu800u82elisttoformat frame local lists local pformat frameu82eargs "format" local sepu800 frameu82eargs "sepu800" oru800 ";" parameter parsen listen foru800 ku800 vu800 inu800 pairs frameu82eargs dou800 local knum tonumber ku800 ifu800 knum then lists knum vu800 endu800 endu800 listen splitten local maxlistlen 0u800 foru800 iu800 1u800 #lists dou800 lists iu800 mwu800u82etextu82esplit lists iu800 sepu800 ifu800 #lists iu800 maxlistlen then maxlistlen #lists iu800 endu800 endu800 ergebnisstring generieren local result "" local result_line "" foru800 iu800 1u800 maxlistlen dou800 result_line pformat foru800 ju800 1u800 #lists dou800 result_line mwu800u82eustringu82egsub result_line " su800" lists ju800 iu800 1u800 endu800 result result .. result_line endu800 return result endu800 function pu800u82elisttotext frame local args local template frameu82eargsu82etemplate ifu800 type template "string" then template mwu800u82etextu82etrim template template template "1u800" endu800 ifu800 template then args frame getparent .args else args frameu82eargs endu800 return textu82elisttotext args frameu82eargsu82eformat endu800 function pu800u82equote frame local slang frameu82eargs 2u800 ifu800 type slang "string" then slang mwu800u82etextu82etrim slang ifu800 slang "" then slang false endu800 endu800 return textu82equote frameu82eargs 1u800 oru800 "" slang tonumber frameu82eargs 3u800 endu800 function pu800u82equoteunquoted frame local slang frameu82eargs 2u800 ifu800 type slang "string" then slang mwu800u82etextu82etrim slang ifu800 slang "" then slang false endu800 endu800 return textu82equoteunquoted frameu82eargs 1u800 oru800 "" slang tonumber frameu82eargs 3u800 endu800 function pu800u82ezipu800 frame local lists local seps local defaultsep frameu82eargs "sepu800" oru800 "" local innersep frameu82eargs "isep" oru800 "" local outersep frameu82eargs "osep" oru800 "" parameter parsen foru800 ku800 vu800 inu800 pairs frameu82eargs dou800 local knum tonumber ku800 ifu800 knum then lists knum vu800 else ifu800 stringu82esubu800 ku800 1u800 3u800 "sepu800" then local sepnum tonumber stringu82esubu800 ku800 4u800 ifu800 sepnum then seps sepnum vu800 endu800 endu800 endu800 endu800 sofern keine expliziten separatoren angegeben sind denu800 standardseparator verwenden foru800 iu800 1u800 mathu82emaxu800 #seps #lists dou800 ifu800 notu800 seps iu800 then seps iu800 defaultsep endu800 endu800 listen splitten local maxlistlen 0u800 foru800 iu800 1u800 #lists dou800 lists iu800 mwu800u82etextu82esplit lists iu800 seps iu800 ifu800 #lists iu800 maxlistlen then maxlistlen #lists iu800 endu800 endu800 local result "" foru800 iu800 1u800 maxlistlen dou800 ifu800 iu800 1u800 then result result .. outersep endu800 foru800 ju800 1u800 #lists dou800 ifu800 ju800 1u800 then result result .. innersep endu800 result result .. lists ju800 iu800 oru800 "" endu800 endu800 return result endu800 function pu800u82efailsafe return textu82eserial endu800 pu800u82etext function return text endu800 pu800u82etext return pu800 