Modul:Sort: Unterschied zwischen den Versionen

2.800 Bytes hinzugefügt ,  vor 10 Jahren
2015-03-30
w>PerfektesChaos
(2015-03-14)
w>PerfektesChaos
(2015-03-30)
Zeile 1: Zeile 1:
--[=[ 2015-03-14
--[=[ 2015-03-30
Sort
Sort
]=]
]=]
Zeile 18: Zeile 18:
     --                "DIN5007m2"  -- DIN 5007 mode "2"
     --                "DIN5007m2"  -- DIN 5007 mode "2"
     local r = adjust
     local r = adjust
     if not r:match( "^[ -~]*$" ) then
     if adapt  or  not r:match( "^[ -~]*$" ) then
         local lucky
         local storage = "Module:Sort/"
         local collate
         local collate, lucky, post, pre
         if apply then
         if apply then
             collate = apply
             collate = apply
Zeile 26: Zeile 26:
             collate = "uni"
             collate = "uni"
         end
         end
         if adapt then
        lucky, collate = pcall( mw.loadData,  storage .. collate )
             collate = collate .. adapt
         if adapt and  type( collate ) == "table" then
             local variants = mw.text.split( adapt, "%s+" )
            local n = #variants
            if n == 1  and  variants[ 1 ] == "" then
                n = 0
            end
            if n > 0 then
                local tmp = { }
                local var
                for k, v in pairs( collate ) do
                    tmp[ k ] = v
                end    -- for k, v
                collate = tmp
                for i = 1, n do
                    lucky, tmp = pcall( mw.loadData,
                                        storage .. variants[ i ] )
                    if type( tmp ) == "table" then
                        var = tmp.single
                        if type( var ) ~= "table" then
                            -- legacy
                            var = tmp
                        end
                        if type( var ) == "table" then
                            for k, v in pairs( var ) do
                                collate[ k ] = v
                            end    -- for k, v
                        end
                        var = tmp.pre
                        if type( var ) == "table" then
                            if type( pre ) ~= "table" then
                                pre = { }
                            end
                            for k, v in pairs( var ) do
                                pre[ k ] = v
                            end    -- for k, v
                        end
                        var = tmp.post
                        if type( var ) == "table" then
                            if type( post ) ~= "table" then
                                post = { }
                            end
                            for k, v in pairs( var ) do
                                post[ k ] = v
                            end    -- for k, v
                        end
                    elseif lucky then
                        collate = "Invalid table " .. variants[ i ]
                        break    -- for i
                    else
                        collate = tmp
                        break    -- for i
                    end
                end    -- for i
            end
         end
         end
        collate = "Module:Sort/" .. collate
        lucky, collate = pcall( mw.loadData, collate )
         if type( collate ) == "table" then
         if type( collate ) == "table" then
             local k, n, s, start
             local k, n, s, start
             local n = mw.ustring.len( r )
             if type( pre ) == "table" then
                for k, v in pairs( pre ) do
                    r = mw.ustring.gsub( r, k, v )
                end    -- for k, v
            end
            n = mw.ustring.len( r )
             for i = n, 1, -1 do
             for i = n, 1, -1 do
                 k = mw.ustring.codepoint( r, i, i )
                 k = mw.ustring.codepoint( r, i, i )
Zeile 41: Zeile 97:
                         s = " "
                         s = " "
                     end
                     end
                 elseif k >= 768 and  k <= 866 then
                 elseif (k >=   768 and  k <=   866)  or
                      (k >=  6832  and  k <=  6911)  or
                      (k >=  7616  and  k <=  7679)  or
                      (k >= 65056  and  k <= 65071) then
                     -- COMBINING ...
                     -- COMBINING ...
                     s = ""
                     s = ""
Zeile 54: Zeile 113:
                 end
                 end
             end    -- for i--
             end    -- for i--
            if type( post ) == "table" then
                for k, v in pairs( post ) do
                    r = mw.ustring.gsub( r, k, v )
                end    -- for k, v
            end
         else
         else
             r = "**ERROR** Sort.lex ** Submodule unavailable " .. collate
             r = "**ERROR** Sort.lex ** Submodule unavailable " .. collate
        end
        if type( post ) == "table" then
         end
         end
     end
     end
Anonymer Benutzer