Edge Rewrite
// HTMLRewriter · presentation

This page was redesigned at the edge.

Cloudflare fetched the original article and streamed it through HTMLRewriter to apply an entirely new visual system without rebuilding the source page.

// request.cf · coarse context

A page that knows where it met you.

Only coarse request metadata is shown. This demo does not display or persist visitor IP addresses.

Country
US
Cloudflare location
CMH
Connection
HTTP/2
Language
Not provided

Ray ID: a3ff15711e713564

Jump to content

Module:Driver standings

From Wikipedia, the free encyclopedia

  1. ^ Thank you for being here!
local p = {}

function p.standings(frame)
	local getArgs = require('Module:Arguments').getArgs
	local args = getArgs(frame, {parentFirst = true})
    -- iteration count: 3x3 = 405 -> 325 -> 370 -> 399
    --[[ to do list
    0. add championships
    0. clean up functions
    0. documentation
    0. remove dependence on championship
    1. allow classify to not classify drivers
    2. standardize results [tonumber or upper]?
    3. add year functionality
    4. simplify how drivers, teams, and manufacturers are added (USE SEPARATORS!)
    5. create retrieval of results/statistics
    6. add eligibility
    7. make cancellation a race attribute and not a driver result attribute
    8. build collage to create points/color/display systems
    -. recreate this using OOP
    ]]
    -- colors
    local colors = {gold='#FFFFBF', silver='#DFDFDF', bronze='#FFDF9F', green='#DFFFDF', light_blue='#CFEAFF', dark_blue='#CFCFFF', purple='#EFCFFF', red='#FFCFCF', brown='#DFC484', black='#000000; color: white', white='#FFFFFF', blank='#; color: white', empty='#'}
    -- example points system
    -- {['1'], ['2'], ['3'], ['4'], ['5'], ['6'], ['7'], ['8'], ['9'], ['10'], ['11'], ['12'], ['13'], ['14'], ['15'], ['16'], ['17'], ['18'], ['19'], ['20'], ['21'], ['22'], ['23'], ['24'], ['25'], ['26'], ['27'], ['28'], ['29'], ['30'], ['31'], ['32'], ['33'], ['34'], ['35'], ['36'], ['37'], ['38'], ['39'], ['40'], ['41'], ['42'], ['43'], ['44'], ['45'], ['46'], ['47'], ['48'], ['49'], ['50'], ['51'], ['52'], ['53'], ['54'], ['55'], ['56'], ['57'], ['58'], ['59'], ['60'], ['61'], ['62'], ['63'], ['64'], ['65'], ['66'], ['67'], ['68'], ['69'], ['70'], ['71'], ['72'], ['73'], ['74'], ['75'], ['76'], ['77'], ['78'], ['79'], ['80'], ['81'], ['82'], ['83'], ['84'], ['85'], ['86'], ['87'], ['88'], ['89'], ['90'], ['91'], ['92'], ['93'], ['94'], ['95'], ['96'], ['97'], ['98'], ['99'], ['100']}
    local ex_main_points_system = {['1']=100, ['2']=90, ['3']=80, ['4']=70, ['5']=60, ['6']=50, ['7']=40, ['8']=30, ['9']=20, ['10']=10, ['11']=0, ['12']=0, ['13']=0, ['14']=0, ['15']=0, ['16']=0, ['17']=0, ['18']=0, ['19']=0, ['20']=0, ['21']=0, ['22']=0, ['23']=0, ['24']=0, ['25']=0, NC=0, Ret=0, DNQ=0, EX=0, DSQ=0, DNS=0, WD=0, DNA=0, C=0, [' ']=0}
    local ex_side_points_system = {['1']=20, ['2']=18, ['3']=16, ['4']=14, ['5']=12, ['6']=10, ['7']=8, ['8']=6, ['9']=4, ['10']=2, P=10, F=4, L=2, M=6}
    local ex_color_system = {['1']=colors['gold'], ['2']=colors['silver'], ['3']=colors['bronze'], ['4']=colors['green'], ['5']=colors['green'], ['6']=colors['green'], ['7']=colors['green'], ['8']=colors['green'], ['9']=colors['green'], ['10']=colors['green'], ['11']=colors['dark_blue'], ['12']=colors['dark_blue'], ['13']=colors['dark_blue'], ['14']=colors['dark_blue'], ['15']=colors['dark_blue'], ['16']=colors['dark_blue'], ['17']=colors['dark_blue'], ['18']=colors['dark_blue'], ['19']=colors['dark_blue'], ['20']=colors['dark_blue'], ['21']=colors['dark_blue'], ['22']=colors['dark_blue'], ['23']=colors['dark_blue'], ['24']=colors['dark_blue'], ['25']=colors['dark_blue'], NC=colors['dark_blue'], Ret=colors['purple'], DNQ=colors['red'], EX=colors['black'], DSQ=colors['black'], DNS=colors['white'], WD=colors['white'], DNA=colors['white'], C=colors['white'], [' ']=colors['empty']}
    local ex_display_system = {['1']='1', ['2']='2', ['3']='3', ['4']='4', ['5']='5', ['6']='6', ['7']='7', ['8']='8', ['9']='9', ['10']='10', ['11']='11', ['12']='12', ['13']='13', ['14']='14', ['15']='15', ['16']='16', ['17']='17', ['18']='18', ['19']='19', ['20']='20', ['21']='21', ['22']='22', ['23']='23', ['24']='24', ['25']='25', NC='NC', Ret='Ret', DNQ='DNQ', EX='EX', DSQ='DSQ', DNS='DNS', WD='WD', DNA='DNA', C='C', [' ']='', P='P', F='F', L='L', M='M'}
    local ex_classification = {'1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', 'NC', 'Ret', 'DNQ', 'EX', 'DSQ', 'DNS', 'WD', 'DNA', 'C', ' '}
    -- functions
    ---- padding function
    local function pad(num) return string.format('%06d', tonumber(num)) end
    ---- ascending alphanumeric and descending alphanumeric sorting functions
    local function alphanum(x, y)
        return x:gsub('(%d+)', pad) < y:gsub('(%d+)', pad)
    end
    ---- identical function
    local function identical(table1, table2)
        local function truth(t1, t2, t)
            for i=1, math.min(#t1, #t2) do
                if type(t1[i]) == 'table' and type(t2[i]) == 'table' then
                    truth(t1[i], t2[i], t)
                elseif t1[i] ~= t2[i] then
                    t = t + 1
                end
            end
            return t == 0
        end
        return truth(table1, table2, 0)
    end
    ---- includes function
    local function includes(array, value)
        for i, v in ipairs(array) do
            if type(v) == 'table' and type(value) == 'table' then
                return identical(v, value)
            elseif type(v) == 'table' then
                return includes(v, value)
            elseif v == value then
                return true
            end
        end
        return false
    end
	---- index function
    local function index(array, value)
        for i, v in ipairs(array) do
            if type(v) == 'table' and type(value) == 'table' and identical(v, value) or type(v) == 'table' and includes(v, value) or v == value then
                return i
            end
        end
        return nil
    end
    ---- systems creating function

    ---- shortened race calculating function
    local function clip(championship, r, distance, pps)
        if 0 < distance and distance <= 0.25 then
            if r == '1' then
                return 6
            elseif r >= '2' and r <= '5' then
                return 6 - tonumber(r)
            else
                return 0
            end
        elseif 0.25 < distance and distance <= 0.5 then
            if r < '4' then
                return math.floor(pps[r]*0.5)
            else
                return math.ceil(pps[r]*0.5)
            end
        elseif 0.5 < distance and distance <= 0.75 then
            return math.ceil(pps[r]*0.75)
        elseif 0.75 < distance then
            return pps[r]
        end
    end
    ---- points calculating function
    local function calculate(championship, rlengths, rdistances, results, penalties, pps, sps)
        local points = {}
        for id, result in ipairs(results) do
            local pts = 0
            for i, r in ipairs(result) do
                local sub = {}
                if type(r) == 'table' then
                    for s=2, #r do
                        table.insert(sub, r[s])
                    end
                    r = r[1]
                end
                if r:find('=') then
                    local _, eqe = r:find('=')
                    r = r:sub(eqe+1)
                end
                if r:match('^%u%d+$') then
                    r = r:sub(2)
                end
                if rdistances[i] then
                    pts = pts + clip(championship, r, rdistances[i], pps)
                end
                if rlengths[i] then
                    pts = pts + pps[r][rlengths[i]]
                else
                    pts = pts + pps[r]
                end
                for _, s in ipairs(sub) do
                    pts = pts + sps[s]
                end
            end
            if penalties[id] then
                local _, pas = penalties[id]:find('%(')
                local pae = penalties[id]:find('%)')
                pts = pts - tonumber(penalties[id]:sub(pas+1, pae-1))
            end
            points[id] = pts
        end
        return points
    end
    ---- points sorting function
    local function classify(championship, results, points, scheme)
        local order, teammates, finishes, empty, unclassified, uc = {}, {}, {}, {}, {}
        for id, _ in ipairs(points) do
            order[id] = id
        end
        if championship == 'GTWCE' then
            uc = index(scheme, '11')
        else
            uc = index(scheme, 'Ret')
        end
        local times = 0
        if results[1] then
            times = #results[1]
        end
        for r=1, times do
            table.insert(empty, ' ')
            if r < uc then
                unclassified[r] = 0
            end
        end
        for id, result in ipairs(results) do
            finishes[id] = {}
            for _, r in ipairs(result) do
                local i
                if type(r) == 'table' then
                    r = r[1]
                end
                if r:find('=') then
                    local _, eqe = r:find('=')
                    r = r:sub(eqe+1)
                end
                if r:match('^%u%d+') then
                    i = index(scheme, r:sub(2))
                else
                    i = index(scheme, r)
                end
                if finishes[id][i] then
                    finishes[id][i] = finishes[id][i] + 1
                else
                    finishes[id][i] = 1
                end
            end
            for c=1, #scheme do
                if not finishes[id][c] then
                    finishes[id][c] = 0
                end
            end
        end
        local anchor, swapped = #order
        if #order == 0 then
            return {}
        elseif #order == 1 then
            return {{order[1]}}
        end
        repeat
            swapped = false
            for c=1, anchor-1 do
                local separate = false
                if points[order[c]] < points[order[c+1]] then
                    order[c], order[c+1] = order[c+1], order[c]
                    swapped, separate = true, true
                elseif points[order[c]] > points[order[c+1]] then
                    separate = true
                end
                if not separate then
                    for f=1, #scheme do
                        if finishes[order[c]][f] < finishes[order[c+1]][f] then
                            order[c], order[c+1] = order[c+1], order[c]
                            swapped = true
                            break
                        elseif finishes[order[c]][f] > finishes[order[c+1]][f] then
                            break
                        end
                    end
                end
            end
            anchor = anchor - 1
        until not swapped
        anchor = 1
        repeat
            if points[order[anchor]] == 0 then
                if identical(results[order[anchor]], empty) then
                    teammates[order[anchor]] = 0
                elseif identical(finishes[order[anchor]], unclassified) then
                    teammates[order[anchor]] = -1
                end
            end
            if points[order[anchor+1]] == 0 then
                if identical(results[order[anchor+1]], empty) then
                    teammates[order[anchor+1]] = 0
                elseif identical(finishes[order[anchor+1]], unclassified) then
                    teammates[order[anchor+1]] = -1
                end
            end
            if points[order[anchor]] == points[order[anchor+1]] then
                if identical(results[order[anchor]], results[order[anchor+1]]) then
                    if teammates[order[anchor]] then
                        teammates[order[anchor+1]] = teammates[order[anchor]]
                    else
                        teammates[order[anchor]], teammates[order[anchor+1]] = 1, 1
                    end
                elseif identical(finishes[order[anchor]], finishes[order[anchor+1]]) then
                    if teammates[order[anchor]] then
                        teammates[order[anchor+1]] = teammates[order[anchor]] + 1
                    else
                        teammates[order[anchor]], teammates[order[anchor+1]] = 1, 2
                    end
                end
            end
            anchor = anchor + 1
        until anchor >= #order
        local positions, pos = {['-']={}, ['']={}}, 1
        for _, id in ipairs(order) do
            if teammates[id] == -1 then
                table.insert(positions['-'], id)
            elseif teammates[id] == 0 then
                table.insert(positions[''], id)
            elseif teammates[id] then
                if not positions[pos][teammates[id]] then
                    positions[pos][teammates[id]] = {}
                end
                table.insert(positions[pos][teammates[id]], id)
            else
                positions[pos] = {id}
                pos = pos + 1
            end
        end
        return positions
    end
    ---- championship clinched function
    local function clinched(championship, id, drivers, results, points, max, min)
        local specific = {}
        for d, _ in pairs(drivers) do
            table.insert(specific, {d, points[d]})
        end
        table.sort(specific, function(x, y) return x[2] > y[2] end)
        if #specific == 0 then
            return false
        end
        local delta = max - min
        local remaining, left = 0
        for i=1, #specific do
            for r=1, #results[specific[i][1]] do
                if results[specific[i][1]][r] ~= '' and remaining < r then
                    remaining = r
                end
            end
            left = #results[specific[i][1]] - remaining
        end
        if specific[1][1] == id[1] then
            local against
            if #specific == 1 then
                against = 0
            else
                against = points[specific[2][1]]
            end
            if points[id[1]] > against + (delta*left) then
                return true
            end
        end
        return false
    end
    ---- wikitable row function
    local function combine(championship, rdistances, id, drivers, rookies, teams, manufacturers, stints, result, penalty, point, auxpoint, position, auxposition, clinch, pps, sps, cs, ds)
        local row_def, row_results, row_fin = '', {}, ''
        local cell = '| style="background:'
        local num_teams, num_manufacturers = 0, 0
        if teams[id[1]] then
            num_teams = #teams[id[1]]
        end
        if manufacturers[id[1]] then
            num_manufacturers = #manufacturers[id[1]]
        end
        local R = ''
        if rookies[id[1]] then
            if championship == 'INDYCAR' then
                if clinch then
                    R = ' <span style="border: 1px solid silver; padding: 1px 4px; color: black; background-color: yellow;">' .. "'''RY'''" .. '</span>'
                else
                    R = ' <span style="border: 1px solid silver; padding: 1px 3px; color: black; background-color: orange;">' .. "'''R'''" .. '</span>'
                end
            elseif championship == 'MOTOGP' then
                R = ' style="background:#ADD8E6;"'
            end
        end
        if num_teams > 1 then
            row_def = row_def .. '! rowspan="' .. num_teams .. '" | ' .. position .. '\n| rowspan="' .. num_teams .. '"'
        else
            row_def = row_def .. '! ' .. position .. '\n| align="left"'
        end
        if championship == 'MOTOGP' then
            row_def = row_def .. R
        end
        row_def = row_def .. ' | '
        for _, d in ipairs(id) do
            row_def = row_def .. drivers[d] .. '<br>'
        end
        id = id[1]
        row_def = row_def:sub(1, -5)
        if championship == 'INDYCAR' then
            row_def = row_def .. R
        end
        row_def = row_def .. '\n'
        local first, last, stint = 1, #result, 1
        if num_teams > 1 then
            first, last = tonumber(stints[id][1][stint]), tonumber(stints[id][1][stint+1])
        end
        local t = 1
        repeat
            local row_races = ''
            if num_teams > 0 then
                if championship == 'MOTOGP' then
                    row_races = row_races .. '| ' .. teams[id][t] .. '\n'
                else
                    row_races = row_races .. '| align="left" | ' .. teams[id][t] .. '\n'
                end
            end
            if num_teams > 1 then
                first = tonumber(stints[id][t][stint]) or first
                last = tonumber(stints[id][t][stint+1]) or last
            end
            if num_manufacturers > 0 then
                if championship == 'MOTOGP' then
                    row_races = row_races .. '| ' .. manufacturers[id][t] .. '\n'
                else
                    row_races = row_races .. '| align="left" | ' .. manufacturers[id][t] .. '\n'
                end
            end
            for i, r in ipairs(result) do
                local bg
                local face, sup = {}, {}
                if type(r) == 'table' then
                    for s=2, #r do
                        if ds[r[s]]:find("'") then
                            table.insert(face, r[s])
                        else
                            table.insert(sup, r[s])
                        end
                    end
                    r = r[1]
                end
                if r:match('%w+=%w+') then
                    local eqs, eqe = r:find('=')
                    bg = cs[r:sub(eqe+1)]
                    r = ds[r:sub(1, eqs-1)]
                elseif r:match('^R%d+$') then
                    bg = cs['Ret']
                    r = ds[r:sub(2)]
                elseif r:match('^N%d+') then
                    bg = cs['NC']
                    r = ds[r:sub(2)] .. '&dagger;'
                elseif r:match('^D%d+') then
                    bg = cs['DSQ']
                    r = ds[r:sub(2)]
                elseif championship == 'WRC' then
                    bg = cs[r] .. '; padding: 1em'
                    r = ds[r]
                else
                    bg = cs[r]
                    r = ds[r]
                end
                if rdistances[i] then
                    if 0.25 < rdistances[i] and rdistances[i] <= 0.5 then
                        if '5' < r and r < '11' then
                            bg = cs['NC']
                        end
                    elseif 0 < rdistances[i] and rdistances[i] <= 0.25 then
                        if r == '10' then
                            bg = cs['NC']
                        end
                    end
                end
                for _, tf in ipairs(face) do
                    r = ds[tf] .. r .. ds[tf]
                end
                if i < first or i > last then
                    bg, r = colors['empty'], ''
                end
                row_races = row_races .. cell .. bg .. ';" | '
                if championship == 'WRC' and r ~= '' then
                    row_races = row_races .. '<div class="sfrac nowrap;">'
                end
                row_races = row_races .. r
                if championship == 'WRC' and r ~= '' then
                    row_races = row_races .. '</div><div style="line-height: 1em; font-size: 85%; padding: 0 0;"><small>' .. pps[r]
                    for _, s in ipairs(sup) do
                        row_races = row_races .. '+' .. sps[s]
                    end
                    row_races = row_races .. '</small></div>'
                    sup = {}
                elseif championship == 'WRC' or championship == 'IMSA' then
                    sup = {}
                end
                for _, s in ipairs(sup) do
                    row_races = row_races .. "<sup>''' " .. ds[s] .. "'''</sup>"
                end
                row_races = row_races .. '\n'
                if i == last then
                    stint = stint + 2
                    if num_teams > 1 then
                        first = tonumber(stints[id][t][stint]) or first
                        last = tonumber(stints[id][t][stint+1]) or last
                    end
                end
            end
            table.insert(row_results, row_races)
            stint = 1
            t = t + 1
        until t > num_teams
        if num_teams > 1 then
            row_fin = row_fin .. '! style="position: sticky; right: 0; background-clip: padding-box; color: inherit;" rowspan="' .. num_teams .. '" | '
        else
            row_fin = row_fin .. '! style="position: sticky; right: 0; background-clip: padding-box; color: inherit;" | '
        end
        if penalty then
            local _, pae = penalty:find('%)')
            row_fin = row_fin .. '<span style="text-decoration: underline dotted; cursor: help;" Title="' .. penalty:sub(pae+2) .. '">'
        end
        row_fin = row_fin .. point
        if penalty then
            row_fin = row_fin .. '</span>'
        end
        row_fin = row_fin .. '\n'
        if auxposition then
            if num_teams > 1 then
                row_fin = row_fin .. '! rowspan="' .. num_teams .. '" '
            else
                row_fin = row_fin .. '! '
            end
            if auxposition == '' then
            elseif auxposition <= 3 then
                row_fin = row_fin .. 'style="background:' .. cs[tostring(auxposition)]
            end
        end
        if auxpoint then
            if num_teams > 1 or tostring(auxposition) <= '3' and auxposition ~= '' then
                row_fin = row_fin .. ' | '
            end
            row_fin = row_fin .. auxpoint .. '\n'
        end
        row_fin = row_fin .. '|-\n'
        local row = row_def .. row_results[1] .. row_fin
        for t=2, #row_results do
            row = row .. row_results[t] .. '|-\n'
        end
        return row
    end
    ---- wikitable creating function
    local function convey(championship, races, subraces, rdistances, drivers, rookies, teams, manufacturers, stints, results, penalties, points, auxillary_points, positions, auxillary_positions, pps, sps, cs, ds, sources)
        local pos_column, comp_column, team_column, man_column, points_column, aux_column = args['position'] or 'Pos', args['competitor'] or 'Driver', args['team'] or 'Team', args['manufacturer'] or 'Manufacturer', args['point'] or 'Points', args['auxchampionship'] or ''
        local def = '<div style="overflow-x: auto;">\n{| class="wikitable" style="font-size: 85%; white-space: nowrap; text-align: center; border: 1px solid #A2A9B1;"\n|-\n'
        local header = '! ' .. pos_column .. '\n! ' .. comp_column .. '\n'
        local data = ''
        local rows = {}
        local rowbreak = '|-\n'
        local fin = '|}\n</div>'
        local num_sraces, num_eraces = 0, 0
        local num_columns = 0
        for _, s in pairs(subraces) do
            if identical(s, {'', '', '', ''}) then
                num_eraces = num_eraces + #s
            else
                num_sraces = num_sraces + #s
            end
        end
        if num_sraces > 0 then
            header = '! rowspan="2" | ' .. pos_column .. '\n! rowspan="2" | ' .. comp_column .. '\n'
        end
        if #teams > 0 then
            if num_sraces > 0 then
                header = header .. '! rowspan="2" | ' .. team_column .. '\n'
            else
                header = header .. '! ' .. team_column .. '\n'
            end
        end
        if #manufacturers > 0 then
            header = header .. '! ' .. man_column .. '\n'
        end
        for r=1, #races do
            if subraces[r] then
                header = header .. '! colspan="' .. #subraces[r] .. '" | ' .. races[r] .. '\n'
            elseif num_sraces > 0 then
                header = header .. '! rowspan="2" | ' .. races[r] .. '\n'
            else
                header = header .. '! ' .. races[r] .. '\n'
            end
        end
        if num_sraces > 0 then
            header = header .. '! style="border: 1px solid #A2A9B1; position: sticky; right: 0; background-clip: padding-box; color: inherit;" rowspan="2" | ' .. points_column .. '\n'
        else
            header = header .. '! style="border: 1px solid #A2A9B1; position: sticky; right: 0; background-clip: padding-box; color: inherit;" | ' .. points_column .. '\n'
        end
        if #auxillary_positions > 0 then
            if num_sraces > 0 then
                header = header .. '! rowspan="2" | ' .. aux_column .. '\n'
            else
                header = header .. '! ' .. aux_column .. '\n'
            end
        end
        header = header .. rowbreak
        for r=1, #races do
            if subraces[r] then
                for _, sr in ipairs(subraces[r]) do
                    if sr ~= '' then
                        header = header .. '! ' .. sr .. '\n'
                    end
                end
            end
        end
        if num_sraces > 0 then
            header = header .. rowbreak
        end
        local finishing_positions = {}
        for pos, _ in ipairs(positions) do
            table.insert(finishing_positions, pos)
        end
        table.insert(finishing_positions, '-')
        table.insert(finishing_positions, '')
        for _, pos in ipairs(finishing_positions) do
            local row, extract
            for _, i in ipairs(positions[pos] or {}) do
                local id
                if type(i) == 'table' then
                    extract = i[1]
                    id = i
                else
                    extract = i
                    id = {i}
                end
                if championship == 'F1' then
                    row = combine(championship, rdistances, id, drivers, {}, {}, {}, {}, results[extract], nil, points[extract], nil, pos, nil, nil, pps, sps, cs, ds)
                elseif championship == 'WRC' then
                    row = combine(championship, {}, id, drivers, {}, {}, {}, {}, results[extract], nil, points[extract], nil, pos, nil, nil, pps, sps, cs, ds)
                elseif championship == 'INDYCAR' then
                    local clinch = clinched(championship, id, rookies, results, points, 54, 0)
                    row = combine(championship, {}, id, drivers, rookies, {}, {}, {}, results[extract], penalties[extract], points[extract], nil, pos, nil, clinch, pps, sps, cs, ds)
                elseif championship == 'WEC' or championship == 'GTWCE' then
                    row = combine(championship, {}, id, drivers, {}, teams, {}, stints, results[extract], nil, points[extract], nil, pos, nil, nil, pps, sps, cs, ds)
                elseif championship == 'IMSA' then
                    row = combine(championship, {}, id, drivers, {}, {}, {}, {}, results[extract], nil, points[extract], auxillary_points[extract], pos, index(auxillary_positions, extract) or '', nil, pps, sps, cs, ds)
                elseif championship == 'MOTOGP' then
                    row = combine(championship, {}, id, drivers, rookies, teams, manufacturers, stints, results[extract], nil, points[extract], nil, pos, nil, nil, pps, sps, cs, ds)
                elseif championship == 'FE' then
                    row = combine(championship, {}, id, drivers, {}, {}, {}, {}, results[extract], nil, points[extract], nil, pos, nil, nil, pps, sps, cs, ds)
                else
                    row = combine(nil, {}, id, drivers, rookies, teams, manufacturers, stints, results[extract], penalties[extract], points[extract], nil, pos, nil, nil, pps, sps, cs, ds)
                end
                table.insert(rows, row)
            end
        end
        for _, row in ipairs(rows) do
            data = data .. row
        end
        for _ in header:gmatch('!') do
            num_columns = num_columns + 1
        end
        if sources then
            fin = '! colspan="' .. num_columns .. '" | <small>Sources:</small>' .. sources .. '\n' .. rowbreak .. fin
        end
        local wikitable = ''
        wikitable = wikitable .. def .. header .. data .. header .. fin
        return wikitable
    end
    -- sorting keys
    local keys = {}
    for key, _ in pairs(args) do
        table.insert(keys, key)
    end
    table.sort(keys, alphanum)
    -- variables
    local championship = args['championship']
    local separator = args['separator'] or ','
    local auxseparator = args['auxseparator'] or '/'
    local sources = args['sources']
    local races, rlengths, rdistances = {}, {}, {}
    local subraces = {}
    local num_races, curr_race = 0, 1
    local drivers = {}
    local rookies = {}
    local teams = {}
    local manufacturers = {}
    local stints = {}
    local id = 0
    local results, auxresults = {}, {}
    local penalties = {}
    -- THE FOR LOOP
    for _, key in ipairs(keys) do
        if key:match('^d%d+$') then
            id = tonumber(key:sub(2))
            drivers[id] = args[key]
            teams[id] = {''}
            manufacturers[id] = {''}
            stints[id] = {}
            results[id] = {}
            auxresults[id] = {}
            curr_race = 1
        end
        if key:match('^d' .. id .. 'r%d+$') then
            if not key:match('^d' .. id .. 'r' .. curr_race) then
                curr_race = tonumber(key:sub(3+#tostring(id)))
            end
            local result, auxresult = args[key]
            if result:find(auxseparator) then
                local stind, endig = result:find(auxseparator)
                auxresult = result:sub(endig+1)
                result = result:sub(1, stind-1)
            end
            if result:find(separator) then
                results[id][curr_race] = {}
                for r in result:gmatch('%w+') do
                    table.insert(results[id][curr_race], r)
                end
            else
                results[id][curr_race] = result
            end
            if auxresult then
                for a in auxresult:gmatch('%w+') do
                    table.insert(auxresults[id], a)
                end
            end
            curr_race = curr_race + 1
        end
        if key:match('^d' .. id .. 'R$') then
            rookies[id] = true
        end
        if key:match('^d' .. id .. 'm%d+$') then
            local mid = tonumber(key:sub(3+#tostring(id)))
            manufacturers[id][mid] = args[key]
        end
        if key:match('^d' .. id .. 'p$') then
            penalties[id] = args[key]
        end
        if key:match('^d' .. id .. 't%d+$') then
            local tid = tonumber(key:sub(3+#tostring(id)))
            teams[id][tid] = args[key]
            if not manufacturers[id][tid] then
                manufacturers[id][tid] = ''
            end
        end
        if key:match('^d' .. id .. 'e%d+$') then
            local sid = tonumber(key:sub(3+#tostring(id)))
            stints[id][sid] = {}
            for st in args[key]:gmatch('%d+') do
                table.insert(stints[id][sid], tonumber(st))
            end
        end
        if key:match('^r%d+$') then
            num_races = num_races + 1
            races[num_races] = args[key]
        end
        if key:match('^r' .. num_races .. 's$') then
            subraces[num_races] = {}
            for s=1, tonumber(args[key]) do
                table.insert(subraces[num_races], '')
            end
        end
        if key:match('^r' .. num_races .. 's%d+$') then
            if not subraces[num_races] then
                subraces[num_races] = {}
            end
            table.insert(subraces[num_races], args[key])
        end
        if key:match('^r' .. num_races .. 'l$') then
            rlengths[num_races] = args[key]
        end
        if key:match('^r' .. num_races .. 'd$') then
            rdistances[num_races] = tonumber(args[key])
        end
    end
    -- unentered races
    for _, s in pairs(subraces) do
        num_races = num_races + (#s-1)
    end
    for d=1, #drivers do
        for u=1, num_races do
            if not results[d][u] then
                results[d][u] = ' '
            end
        end
    end
    -- championships
    ---- F1
    local function F1(championship, races, rdistances, drivers, results, sources)
        -- points systems
        ---- current points system
        local F1_points_system = {['1']=25, ['2']=18, ['3']=15, ['4']=12, ['5']=10, ['6']=8, ['7']=6, ['8']=4, ['9']=2, ['10']=1, ['11']=0, ['12']=0, ['13']=0, ['14']=0, ['15']=0, ['16']=0, ['17']=0, ['18']=0, ['19']=0, ['20']=0, ['21']=0, ['22']=0, ['23']=0, ['24']=0, ['25']=0, ['26']=0, NC=0, Ret=0, DNQ=0, DSQ=0, DNS=0, C=0, DNP=0, EX=0, DNA=0, WD=0, [' ']=0}
        local F1_sprint_points_system = {['1']=8, ['2']=7, ['3']=6, ['4']=5, ['5']=4, ['6']=3, ['7']=2, ['8']=1, P=0, F=0}
        local F1_color_system = {['1']=colors['gold'], ['2']=colors['silver'], ['3']=colors['bronze'], ['4']=colors['green'], ['5']=colors['green'], ['6']=colors['green'], ['7']=colors['green'], ['8']=colors['green'], ['9']=colors['green'], ['10']=colors['green'], ['11']=colors['dark_blue'], ['12']=colors['dark_blue'], ['13']=colors['dark_blue'], ['14']=colors['dark_blue'], ['15']=colors['dark_blue'], ['16']=colors['dark_blue'], ['17']=colors['dark_blue'], ['18']=colors['dark_blue'], ['19']=colors['dark_blue'], ['20']=colors['dark_blue'], ['21']=colors['dark_blue'], ['22']=colors['dark_blue'], ['23']=colors['dark_blue'], ['24']=colors['dark_blue'], ['25']=colors['dark_blue'], ['26']=colors['dark_blue'], NC=colors['dark_blue'], Ret=colors['purple'], DNQ=colors['red'], DSQ=colors['black'], DNS=colors['white'], C=colors['white'], DNP=colors['blank'], EX=colors['blank'], DNA=colors['blank'], WD=colors['blank'], [' ']=colors['empty']}
        local F1_display_system = {['1']='1', ['2']='2', ['3']='3', ['4']='4', ['5']='5', ['6']='6', ['7']='7', ['8']='8', ['9']='9', ['10']='10', ['11']='11', ['12']='12', ['13']='13', ['14']='14', ['15']='15', ['16']='16', ['17']='17', ['18']='18', ['19']='19', ['20']='20', ['21']='21', ['22']='22', ['23']='23', ['24']='24', ['25']='25', ['26']='26', NC='NC', Ret='Ret', DNQ='DNQ', DSQ='DSQ', DNS='DNS', C='C', DNP='DNP', EX='EX', DNA='DNA', WD='WD', [' ']='', P='P', F='F'}
        local F1_classification = {'1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', 'NC', 'Ret', 'DNQ', 'DSQ', 'DNS', 'C', 'DNP', 'EX', 'DNA', 'WD', ' '}
        -- points
        local points = calculate(championship, {}, rdistances, results, {}, F1_points_system, F1_sprint_points_system)
        -- positions
        local positions = classify(championship, results, points, F1_classification)
        -- table
        local wikitable = convey(championship, races, {}, rdistances, drivers, {}, {}, {}, {}, results, {}, points, {}, positions, {}, F1_points_system, F1_sprint_points_system, F1_color_system, F1_display_system, sources)
        return wikitable
    end
    ---- INDYCAR
    local function INDYCAR(championship, races, subraces, drivers, rookies, results, penalties, sources)
        -- points system
        ---- current points system
        local IC_points_system = {['1']=50, ['2']=40, ['3']=35, ['4']=32, ['5']=30, ['6']=28, ['7']=26, ['8']=24, ['9']=22, ['10']=20, ['11']=19, ['12']=18, ['13']=17, ['14']=16, ['15']=15, ['16']=14, ['17']=13, ['18']=12, ['19']=11, ['20']=10, ['21']=9, ['22']=8, ['23']=7, ['24']=6, ['25']=5, ['26']=5, ['27']=5, ['28']=5, ['29']=5, ['30']=5, ['31']=5, ['32']=5, ['33']=5, Ret=0, DNQ=0, Wth=0, DSQ=0, DNS=0, C=0, [' ']=0}
        local IC_inline_points_system = {['1']=12, ['2']=11, ['3']=10, ['4']=9, ['5']=8, ['6']=7, ['7']=6, ['8']=5, ['9']=4, ['10']=3, ['11']=2, ['12']=1, P=1, F=0, L=1, M=2, C=0}
        local IC_color_system = {['1']=colors['gold'], ['2']=colors['silver'], ['3']=colors['bronze'], ['4']=colors['green'], ['5']=colors['green'], ['6']=colors['light_blue'], ['7']=colors['light_blue'], ['8']=colors['light_blue'], ['9']=colors['light_blue'], ['10']=colors['light_blue'], ['11']=colors['dark_blue'], ['12']=colors['dark_blue'], ['13']=colors['dark_blue'], ['14']=colors['dark_blue'], ['15']=colors['dark_blue'], ['16']=colors['dark_blue'], ['17']=colors['dark_blue'], ['18']=colors['dark_blue'], ['19']=colors['dark_blue'], ['20']=colors['dark_blue'], ['21']=colors['dark_blue'], ['22']=colors['dark_blue'], ['23']=colors['dark_blue'], ['24']=colors['dark_blue'], ['25']=colors['dark_blue'], ['26']=colors['dark_blue'], ['27']=colors['dark_blue'], ['28']=colors['dark_blue'], ['29']=colors['dark_blue'], ['30']=colors['dark_blue'], ['31']=colors['dark_blue'], ['32']=colors['dark_blue'], ['33']=colors['dark_blue'], Ret=colors['purple'], DNQ=colors['red'], Wth=colors['brown'], DSQ=colors['black'], DNS=colors['white'], C=colors['white'], [' ']=colors['empty']}
        local IC_display_system = {['1']='1', ['2']='2', ['3']='3', ['4']='4', ['5']='5', ['6']='6', ['7']='7', ['8']='8', ['9']='9', ['10']='10', ['11']='11', ['12']='12', ['13']='13', ['14']='14', ['15']='15', ['16']='16', ['17']='17', ['18']='18', ['19']='19', ['20']='20', ['21']='21', ['22']='22', ['23']='23', ['24']='24', ['25']='25', ['26']='26', ['27']='27', ['28']='28', ['29']='29', ['30']='30', ['31']='31', ['32']='32', ['33']='33', Ret='Ret', DNQ='DNQ', Wth='Wth', DSQ='DSQ', DNS='DNS', C='C', [' ']='', P="'''", F="''", L='L', M='*', c='c'}
        local IC_classification = {'1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', 'Ret', 'DNQ', 'Wth', 'DSQ', 'DNS', 'C', ' '}
        -- points
        local points = calculate(championship, {}, {}, results, penalties, IC_points_system, IC_inline_points_system)
        -- positions
        local positions = classify(championship, results, points, IC_classification)
        -- table
        local wikitable = convey(championship, races, subraces, {}, drivers, rookies, {}, {}, {}, results, penalties, points, {}, positions, {}, IC_points_system, IC_inline_points_system, IC_color_system, IC_display_system, sources)
        return wikitable
    end
    ---- WRC
    local function WRC(championship, races, drivers, results, sources)
        -- points system
        ---- current points system
        local WRC_points_system = {['1']=25, ['2']=17, ['3']=15, ['4']=12, ['5']=10, ['6']=8, ['7']=6, ['8']=4, ['9']=2, ['10']=1, ['11']=0, ['12']=0, ['13']=0, ['14']=0, ['15']=0, ['16']=0, ['17']=0, ['18']=0, ['19']=0, ['20']=0, ['21']=0, ['22']=0, ['23']=0, ['24']=0, ['25']=0, ['26']=0, ['27']=0, ['28']=0, ['29']=0, ['30']=0, ['31']=0, ['32']=0, ['33']=0, ['34']=0, ['35']=0, ['36']=0, ['37']=0, ['38']=0, ['39']=0, ['40']=0, ['41']=0, ['42']=0, ['43']=0, ['44']=0, ['45']=0, ['46']=0, ['47']=0, ['48']=0, ['49']=0, ['50']=0, ['51']=0, ['52']=0, ['53']=0, ['54']=0, ['55']=0, ['56']=0, ['57']=0, ['58']=0, ['59']=0, ['60']=0, ['61']=0, ['62']=0, ['63']=0, ['64']=0, ['65']=0, ['66']=0, ['67']=0, ['68']=0, ['69']=0, ['70']=0, ['71']=0, ['72']=0, ['73']=0, ['74']=0, ['75']=0, ['76']=0, ['77']=0, ['78']=0, ['79']=0, ['80']=0, ['81']=0, ['82']=0, ['83']=0, ['84']=0, ['85']=0, ['86']=0, ['87']=0, ['88']=0, ['89']=0, ['90']=0, ['91']=0, ['92']=0, ['93']=0, ['94']=0, ['95']=0, ['96']=0, ['97']=0, ['98']=0, ['99']=0, ['100']=0, NC=0, Ret=0, EX=0, DSQ=0, DNS=0, C=0, WD=0, [' ']=0}
        local WRC_sunday_points_system = {['1']=5, ['2']=4, ['3']=3, ['4']=2, ['5']=1, ['6']=0, ['7']=0, ['8']=0, ['9']=0, ['10']=0, ['11']=0, ['12']=0, ['13']=0, ['14']=0, ['15']=0, ['16']=0, ['17']=0, ['18']=0, ['19']=0, ['20']=0, ['21']=0, ['22']=0, ['23']=0, ['24']=0, ['25']=0, ['26']=0, ['27']=0, ['28']=0, ['29']=0, ['30']=0, ['31']=0, ['32']=0, ['33']=0, ['34']=0, ['35']=0, ['36']=0, ['37']=0, ['38']=0, ['39']=0, ['40']=0, ['41']=0, ['42']=0, ['43']=0, ['44']=0, ['45']=0, ['46']=0, ['47']=0, ['48']=0, ['49']=0, ['50']=0, ['51']=0, ['52']=0, ['53']=0, ['54']=0, ['55']=0, ['56']=0, ['57']=0, ['58']=0, ['59']=0, ['60']=0, ['61']=0, ['62']=0, ['63']=0, ['64']=0, ['65']=0, ['66']=0, ['67']=0, ['68']=0, ['69']=0, ['70']=0, ['71']=0, ['72']=0, ['73']=0, ['74']=0, ['75']=0, ['76']=0, ['77']=0, ['78']=0, ['79']=0, ['80']=0, ['81']=0, ['82']=0, ['83']=0, ['84']=0, ['85']=0, ['86']=0, ['87']=0, ['88']=0, ['89']=0, ['90']=0, ['91']=0, ['92']=0, ['93']=0, ['94']=0, ['95']=0, ['96']=0, ['97']=0, ['98']=0, ['99']=0, ['100']=0}
        local WRC_color_system = {['1']=colors['gold'], ['2']=colors['silver'], ['3']=colors['bronze'], ['4']=colors['green'], ['5']=colors['green'], ['6']=colors['green'], ['7']=colors['green'], ['8']=colors['green'], ['9']=colors['green'], ['10']=colors['green'], ['11']=colors['dark_blue'], ['12']=colors['dark_blue'], ['13']=colors['dark_blue'], ['14']=colors['dark_blue'], ['15']=colors['dark_blue'], ['16']=colors['dark_blue'], ['17']=colors['dark_blue'], ['18']=colors['dark_blue'], ['19']=colors['dark_blue'], ['20']=colors['dark_blue'], ['21']=colors['dark_blue'], ['22']=colors['dark_blue'], ['23']=colors['dark_blue'], ['24']=colors['dark_blue'], ['25']=colors['dark_blue'], ['26']=colors['dark_blue'], ['27']=colors['dark_blue'], ['28']=colors['dark_blue'], ['29']=colors['dark_blue'], ['30']=colors['dark_blue'], ['31']=colors['dark_blue'], ['32']=colors['dark_blue'], ['33']=colors['dark_blue'], ['34']=colors['dark_blue'], ['35']=colors['dark_blue'], ['36']=colors['dark_blue'], ['37']=colors['dark_blue'], ['38']=colors['dark_blue'], ['39']=colors['dark_blue'], ['40']=colors['dark_blue'], ['41']=colors['dark_blue'], ['42']=colors['dark_blue'], ['43']=colors['dark_blue'], ['44']=colors['dark_blue'], ['45']=colors['dark_blue'], ['46']=colors['dark_blue'], ['47']=colors['dark_blue'], ['48']=colors['dark_blue'], ['49']=colors['dark_blue'], ['50']=colors['dark_blue'], ['51']=colors['dark_blue'], ['52']=colors['dark_blue'], ['53']=colors['dark_blue'], ['54']=colors['dark_blue'], ['55']=colors['dark_blue'], ['56']=colors['dark_blue'], ['57']=colors['dark_blue'], ['58']=colors['dark_blue'], ['59']=colors['dark_blue'], ['60']=colors['dark_blue'], ['61']=colors['dark_blue'], ['62']=colors['dark_blue'], ['63']=colors['dark_blue'], ['64']=colors['dark_blue'], ['65']=colors['dark_blue'], ['66']=colors['dark_blue'], ['67']=colors['dark_blue'], ['68']=colors['dark_blue'], ['69']=colors['dark_blue'], ['70']=colors['dark_blue'], ['71']=colors['dark_blue'], ['72']=colors['dark_blue'], ['73']=colors['dark_blue'], ['74']=colors['dark_blue'], ['75']=colors['dark_blue'], ['76']=colors['dark_blue'], ['77']=colors['dark_blue'], ['78']=colors['dark_blue'], ['79']=colors['dark_blue'], ['80']=colors['dark_blue'], ['81']=colors['dark_blue'], ['82']=colors['dark_blue'], ['83']=colors['dark_blue'], ['84']=colors['dark_blue'], ['85']=colors['dark_blue'], ['86']=colors['dark_blue'], ['87']=colors['dark_blue'], ['88']=colors['dark_blue'], ['89']=colors['dark_blue'], ['90']=colors['dark_blue'], ['91']=colors['dark_blue'], ['92']=colors['dark_blue'], ['93']=colors['dark_blue'], ['94']=colors['dark_blue'], ['95']=colors['dark_blue'], ['96']=colors['dark_blue'], ['97']=colors['dark_blue'], ['98']=colors['dark_blue'], ['99']=colors['dark_blue'], ['100']=colors['dark_blue'], NC=colors['dark_blue'], Ret=colors['purple'], EX=colors['black'], DSQ=colors['black'], DNS=colors['white'], C=colors['white'], WD=colors['blank'], [' ']=colors['empty']}
        local WRC_display_system = {['1']='1', ['2']='2', ['3']='3', ['4']='4', ['5']='5', ['6']='6', ['7']='7', ['8']='8', ['9']='9', ['10']='10', ['11']='11', ['12']='12', ['13']='13', ['14']='14', ['15']='15', ['16']='16', ['17']='17', ['18']='18', ['19']='19', ['20']='20', ['21']='21', ['22']='22', ['23']='23', ['24']='24', ['25']='25', ['26']='26', ['27']='27', ['28']='28', ['29']='29', ['30']='30', ['31']='31', ['32']='32', ['33']='33', ['34']='34', ['35']='35', ['36']='36', ['37']='37', ['38']='38', ['39']='39', ['40']='40', ['41']='41', ['42']='42', ['43']='43', ['44']='44', ['45']='45', ['46']='46', ['47']='47', ['48']='48', ['49']='49', ['50']='50', ['51']='51', ['52']='52', ['53']='53', ['54']='54', ['55']='55', ['56']='56', ['57']='57', ['58']='58', ['59']='59', ['60']='60', ['61']='61', ['62']='62', ['63']='63', ['64']='64', ['65']='65', ['66']='66', ['67']='67', ['68']='68', ['69']='69', ['70']='70', ['71']='71', ['72']='72', ['73']='73', ['74']='74', ['75']='75', ['76']='76', ['77']='77', ['78']='78', ['79']='79', ['80']='80', ['81']='81', ['82']='82', ['83']='83', ['84']='84', ['85']='85', ['86']='86', ['87']='87', ['88']='88', ['89']='89', ['90']='90', ['91']='91', ['92']='92', ['93']='93', ['94']='94', ['95']='95', ['96']='96', ['97']='97', ['98']='98', ['99']='99', ['100']='100', NC='NC', Ret='Ret', EX='EX', DSQ='DSQ', DNS='DNS', C='C', WD='WD', [' ']=''}
        local WRC_classification = {'1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59', '60', '61', '62', '63', '64', '65', '66', '67', '68', '69', '70', '71', '72', '73', '74', '75', '76', '77', '78', '79', '80', '81', '82', '83', '84', '85', '86', '87', '88', '89', '90', '91', '92', '93', '94', '95', '96', '97', '98', '99', '100', 'NC', 'Ret', 'EX', 'DSQ', 'DNS', 'C', 'WD', ' '}
        -- points
        local points = calculate(championship, {}, {}, results, {}, WRC_points_system, WRC_sunday_points_system)
        -- positions
        local positions = classify(championship, results, points, WRC_classification)
        -- table
        local wikitable = convey(championship, races, {}, {}, drivers, {}, {}, {}, {}, results, {}, points, {}, positions, {}, WRC_points_system, WRC_sunday_points_system, WRC_color_system, WRC_display_system, sources)
        return wikitable
    end
    ---- WEC
    local function WEC(championship, races, rlengths, drivers, teams, stints, results, sources)
        -- points system
        ---- current points system
        local WEC_points_system = {['1']={['6']=25, ['8']=38, ['10']=38, ['24']=50}, ['2']={['6']=18, ['8']=27, ['10']=27, ['24']=36}, ['3']={['6']=15, ['8']=23, ['10']=23, ['24']=30}, ['4']={['6']=12, ['8']=18, ['10']=18, ['24']=24}, ['5']={['6']=10, ['8']=15, ['10']=15, ['24']=20}, ['6']={['6']=8, ['8']=12, ['10']=12, ['24']=16}, ['7']={['6']=6, ['8']=9, ['10']=9, ['24']=12}, ['8']={['6']=4, ['8']=6, ['10']=6, ['24']=8}, ['9']={['6']=2, ['8']=3, ['10']=3, ['24']=4}, ['10']={['6']=1, ['8']=2, ['10']=2, ['24']=1}, ['11']={['6']=0, ['8']=0, ['10']=0, ['24']=0}, ['12']={['6']=0, ['8']=0, ['10']=0, ['24']=0}, ['13']={['6']=0, ['8']=0, ['10']=0, ['24']=0}, ['14']={['6']=0, ['8']=0, ['10']=0, ['24']=0}, ['15']={['6']=0, ['8']=0, ['10']=0, ['24']=0}, ['16']={['6']=0, ['8']=0, ['10']=0, ['24']=0}, ['17']={['6']=0, ['8']=0, ['10']=0, ['24']=0}, ['18']={['6']=0, ['8']=0, ['10']=0, ['24']=0}, ['19']={['6']=0, ['8']=0, ['10']=0, ['24']=0}, ['20']={['6']=0, ['8']=0, ['10']=0, ['24']=0}, ['21']={['6']=0, ['8']=0, ['10']=0, ['24']=0}, ['22']={['6']=0, ['8']=0, ['10']=0, ['24']=0}, ['23']={['6']=0, ['8']=0, ['10']=0, ['24']=0}, ['24']={['6']=0, ['8']=0, ['10']=0, ['24']=0}, ['25']={['6']=0, ['8']=0, ['10']=0, ['24']=0}, ['26']={['6']=0, ['8']=0, ['10']=0, ['24']=0}, ['27']={['6']=0, ['8']=0, ['10']=0, ['24']=0}, ['28']={['6']=0, ['8']=0, ['10']=0, ['24']=0}, ['29']={['6']=0, ['8']=0, ['10']=0, ['24']=0}, ['30']={['6']=0, ['8']=0, ['10']=0, ['24']=0}, ['31']={['6']=0, ['8']=0, ['10']=0, ['24']=0}, ['32']={['6']=0, ['8']=0, ['10']=0, ['24']=0}, ['33']={['6']=0, ['8']=0, ['10']=0, ['24']=0}, ['34']={['6']=0, ['8']=0, ['10']=0, ['24']=0}, ['35']={['6']=0, ['8']=0, ['10']=0, ['24']=0}, ['36']={['6']=0, ['8']=0, ['10']=0, ['24']=0}, ['37']={['6']=0, ['8']=0, ['10']=0, ['24']=0}, ['38']={['6']=0, ['8']=0, ['10']=0, ['24']=0}, ['39']={['6']=0, ['8']=0, ['10']=0, ['24']=0}, ['40']={['6']=0, ['8']=0, ['10']=0, ['24']=0}, NC={['6']=0, ['8']=0, ['10']=0, ['24']=0}, Ret={['6']=0, ['8']=0, ['10']=0, ['24']=0}, DNQ={['6']=0, ['8']=0, ['10']=0, ['24']=0}, DNPQ={['6']=0, ['8']=0, ['10']=0, ['24']=0}, DSQ={['6']=0, ['8']=0, ['10']=0, ['24']=0}, DNS={['6']=0, ['8']=0, ['10']=0, ['24']=0}, WD={['6']=0, ['8']=0, ['10']=0, ['24']=0}, C={['6']=0, ['8']=0, ['10']=0, ['24']=0}, DNP={['6']=0, ['8']=0, ['10']=0, ['24']=0}, DNA={['6']=0, ['8']=0, ['10']=0, ['24']=0}, EX={['6']=0, ['8']=0, ['10']=0, ['24']=0}, [' ']={['6']=0, ['8']=0, ['10']=0, ['24']=0}}
        local WEC_extra_points_system = {P=1, F=0}
        local WEC_color_system = {['1']=colors['gold'], ['2']=colors['silver'], ['3']=colors['bronze'], ['4']=colors['green'], ['5']=colors['green'], ['6']=colors['green'], ['7']=colors['green'], ['8']=colors['green'], ['9']=colors['green'], ['10']=colors['green'], ['11']=colors['dark_blue'], ['12']=colors['dark_blue'], ['13']=colors['dark_blue'], ['14']=colors['dark_blue'], ['15']=colors['dark_blue'], ['16']=colors['dark_blue'], ['17']=colors['dark_blue'], ['18']=colors['dark_blue'], ['19']=colors['dark_blue'], ['20']=colors['dark_blue'], ['21']=colors['dark_blue'], ['22']=colors['dark_blue'], ['23']=colors['dark_blue'], ['24']=colors['dark_blue'], ['25']=colors['dark_blue'], ['26']=colors['dark_blue'], ['27']=colors['dark_blue'], ['28']=colors['dark_blue'], ['29']=colors['dark_blue'], ['30']=colors['dark_blue'], ['31']=colors['dark_blue'], ['32']=colors['dark_blue'], ['33']=colors['dark_blue'], ['34']=colors['dark_blue'], ['35']=colors['dark_blue'], ['36']=colors['dark_blue'], ['37']=colors['dark_blue'], ['38']=colors['dark_blue'], ['39']=colors['dark_blue'], ['40']=colors['dark_blue'], NC=colors['dark_blue'], Ret=colors['purple'], DNQ=colors['red'], DNPQ=colors['red'], DSQ=colors['black'], DNS=colors['white'], WD=colors['white'], C=colors['white'], DNP=colors['blank'], DNA=colors['blank'], EX=colors['blank'], [' ']=colors['empty']}
        local WEC_display_system = {['1']='1', ['2']='2', ['3']='3', ['4']='4', ['5']='5', ['6']='6', ['7']='7', ['8']='8', ['9']='9', ['10']='10', ['11']='11', ['12']='12', ['13']='13', ['14']='14', ['15']='15', ['16']='16', ['17']='17', ['18']='18', ['19']='19', ['20']='20', ['21']='21', ['22']='22', ['23']='23', ['24']='24', ['25']='25', ['26']='26', ['27']='27', ['28']='28', ['29']='29', ['30']='30', ['31']='31', ['32']='32', ['33']='33', ['34']='34', ['35']='35', ['36']='36', ['37']='37', ['38']='38', ['39']='39', ['40']='40', NC='NC', Ret='Ret', DNQ='DNQ', DNPQ='DNPQ', DSQ='DSQ', DNS='DNS', WD='WD', C='C', DNP='DNP', DNA='DNA', EX='EX', [' ']='', P="'''", F="''"}
        local WEC_classification = {'1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '40', 'NC', 'Ret', 'DNQ', 'DNPQ', 'DSQ', 'DNS', 'WD', 'C', 'DNP', 'DNA', 'EX', ' '}
        -- points
        local points = calculate(championship, rlengths, {}, results, {}, WEC_points_system, WEC_extra_points_system)
        -- positions
        local positions = classify(championship, results, points, WEC_classification)
        -- table
        local wikitable = convey(championship, races, {}, {}, drivers, {}, teams, {}, stints, results, {}, points, {}, positions, {}, WEC_points_system, WEC_extra_points_system, WEC_color_system, WEC_display_system, sources)
        return wikitable
    end
    ---- IMSA
    local function IMSA(championship, races, drivers, results, auxresults, sources)
        -- points system
        ---- current points system
        local IMSA_points_system = {['1']=350, ['2']=320, ['3']=300, ['4']=280, ['5']=260, ['6']=250, ['7']=240, ['8']=230, ['9']=220, ['10']=210, ['11']=200, ['12']=190, ['13']=180, ['14']=170, ['15']=160, ['16']=150, ['17']=140, ['18']=130, ['19']=120, ['20']=110, ['21']=100, ['22']=90, ['23']=80, ['24']=70, ['25']=60, ['26']=50, ['27']=40, ['28']=30, ['29']=20, ['30']=10, ['31']=10, ['32']=10, ['33']=10, ['34']=10, ['35']=10, ['36']=10, ['37']=10, ['38']=10, ['39']=10, ['40']=10, ['41']=10, ['42']=10, ['43']=10, ['44']=10, ['45']=10, ['46']=10, ['47']=10, ['48']=10, ['49']=10, ['50']=10, ['51']=10, ['52']=10, ['53']=10, ['54']=10, ['55']=10, ['56']=10, ['57']=10, ['58']=10, ['59']=10, ['60']=10, ['61']=10, NC=0, Ret=0, DNQ=0, DNPQ=0, DSQ=0, DNS=0, WD=0, C=0, DNP=0, DNA=0, EX=0, [' ']=0}
        local IMSA_qualifying_points_system = {P=35, ['2']=32, ['3']=30, ['4']=28, ['5']=26, ['6']=25, ['7']=24, ['8']=23, ['9']=22, ['10']=21, ['11']=20, ['12']=19, ['13']=18, ['14']=17, ['15']=16, ['16']=15, ['17']=14, ['18']=13, ['19']=12, ['20']=11, ['21']=10, ['22']=9, ['23']=8, ['24']=7, ['25']=6, ['26']=5, ['27']=4, ['28']=3, ['29']=2, ['30']=1, ['31']=1, ['32']=1, ['33']=1, ['34']=1, ['35']=1, ['36']=1, ['37']=1, ['38']=1, ['39']=1, ['40']=1, ['41']=1, ['42']=1, ['43']=1, ['44']=1, ['45']=1, ['46']=1, ['47']=1, ['48']=1, ['49']=1, ['50']=1, ['51']=1, ['52']=1, ['53']=1, ['54']=1, ['55']=1, ['56']=1, ['57']=1, ['58']=1, ['59']=1, ['60']=1, ['61']=1, F=0, NC=0, Ret=0, DNQ=0, DNPQ=0, DSQ=0, DNS=0, WD=0, C=0, DNP=0, DNA=0, EX=0, [' ']=0}
        local IMSA_MEC_points_system = {['1']=5, ['2']=4, ['3']=3, ['4']=2, ['5']=2, ['6']=2, ['7']=2, ['8']=2, ['9']=2, ['10']=2, ['11']=2, ['12']=2, ['13']=2, ['14']=2, ['15']=2, ['16']=2, ['17']=2, ['18']=2, ['19']=2, ['20']=2, ['21']=2, ['22']=2, ['23']=2, ['24']=2, ['25']=2, ['26']=2, ['27']=2, ['28']=2, ['29']=2, ['30']=2, ['31']=2, ['32']=2, ['33']=2, ['34']=2, ['35']=2, ['36']=2, ['37']=2, ['38']=2, ['39']=2, ['40']=2, ['41']=2, ['42']=2, ['43']=2, ['44']=2, ['45']=2, ['46']=2, ['47']=2, ['48']=2, ['49']=2, ['50']=2, ['51']=2, ['52']=2, ['53']=2, ['54']=2, ['55']=2, ['56']=2, ['57']=2, ['58']=2, ['59']=2, ['60']=2, ['61']=2, NC=0, Ret=0, DNQ=0, DNPQ=0, DSQ=0, DNS=0, WD=0, C=0, DNP=0, DNA=0, EX=0, [' ']=0}
        local IMSA_color_system = {['1']=colors['gold'], ['2']=colors['silver'], ['3']=colors['bronze'], ['4']=colors['green'], ['5']=colors['green'], ['6']=colors['green'], ['7']=colors['green'], ['8']=colors['green'], ['9']=colors['green'], ['10']=colors['green'], ['11']=colors['green'], ['12']=colors['green'], ['13']=colors['green'], ['14']=colors['green'], ['15']=colors['green'], ['16']=colors['green'], ['17']=colors['green'], ['18']=colors['green'], ['19']=colors['green'], ['20']=colors['green'], ['21']=colors['green'], ['22']=colors['green'], ['23']=colors['green'], ['24']=colors['green'], ['25']=colors['green'], ['26']=colors['green'], ['27']=colors['green'], ['28']=colors['green'], ['29']=colors['green'], ['30']=colors['green'], ['31']=colors['green'], ['32']=colors['green'], ['33']=colors['green'], ['34']=colors['green'], ['35']=colors['green'], ['36']=colors['green'], ['37']=colors['green'], ['38']=colors['green'], ['39']=colors['green'], ['40']=colors['green'], ['41']=colors['green'], ['42']=colors['green'], ['43']=colors['green'], ['44']=colors['green'], ['45']=colors['green'], ['46']=colors['green'], ['47']=colors['green'], ['48']=colors['green'], ['49']=colors['green'], ['50']=colors['green'], ['51']=colors['green'], ['52']=colors['green'], ['53']=colors['green'], ['54']=colors['green'], ['55']=colors['green'], ['56']=colors['green'], ['57']=colors['green'], ['58']=colors['green'], ['59']=colors['green'], ['60']=colors['green'], ['61']=colors['green'], NC=colors['dark_blue'], Ret=colors['purple'], DNQ=colors['red'], DNPQ=colors['red'], DSQ=colors['black'], DNS=colors['white'], WD=colors['white'], C=colors['white'], DNP=colors['blank'], DNA=colors['blank'], EX=colors['blank'], [' ']=colors['empty']}
        local IMSA_display_system = {['1']='1', ['2']='2', ['3']='3', ['4']='4', ['5']='5', ['6']='6', ['7']='7', ['8']='8', ['9']='9', ['10']='10', ['11']='11', ['12']='12', ['13']='13', ['14']='14', ['15']='15', ['16']='16', ['17']='17', ['18']='18', ['19']='19', ['20']='20', ['21']='21', ['22']='22', ['23']='23', ['24']='24', ['25']='25', ['26']='26', ['27']='27', ['28']='28', ['29']='29', ['30']='30', ['31']='31', ['32']='32', ['33']='33', ['34']='34', ['35']='35', ['36']='36', ['37']='37', ['38']='38', ['39']='39', ['40']='40', ['41']='41', ['42']='42', ['43']='43', ['44']='44', ['45']='45', ['46']='46', ['47']='47', ['48']='48', ['49']='49', ['50']='50', ['51']='51', ['52']='52', ['53']='53', ['54']='54', ['55']='55', ['56']='56', ['57']='57', ['58']='58', ['59']='59', ['60']='60', ['61']='61', NC='NC', Ret='Ret', DNQ='DNQ', DNPQ='DNPQ', DSQ='DSQ', DNS='DNS', WD='WD', C='C', DNP='DNP', DNA='DNA', EX='EX', [' ']='', P="'''", F="''"}
        local IMSA_classification = {'1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59', '60', '61', 'NC', 'Ret', 'DNQ', 'DNPQ', 'DSQ', 'DNS', 'WD', 'C', 'DNP', 'DNA', 'EX', ' '}
        -- points
        local points = calculate(championship, {}, {}, results, {}, IMSA_points_system, IMSA_qualifying_points_system)
        local MEC_points = calculate('MEC', {}, {}, auxresults, {}, IMSA_MEC_points_system, IMSA_MEC_points_system)
        -- positions
        local positions = classify(championship, results, points, IMSA_classification)
        local MEC_positions = classify('MEC', auxresults, MEC_points, IMSA_classification)
        -- table
        local wikitable = convey(championship, races, subraces, {}, drivers, {}, {}, {}, {}, results, {}, points, MEC_points, positions, MEC_positions, IMSA_points_system, IMSA_qualifying_points_system, IMSA_color_system, IMSA_display_system, sources)
        return wikitable
    end
    ---- GTWC
    local function GTWCE(championship, races, rlengths, subraces, drivers, teams, stints, results, sources)
        -- points system
        ---- current points system
        local GTWCE_points_system = {['1']={['1']=16.5, ['3']=25, ['6']=33, ['12']=12, ['24']=25}, ['2']={['1']=12, ['3']=18, ['6']=24, ['12']=9, ['24']=18}, ['3']={['1']=9.5, ['3']=15, ['6']=19, ['12']=7, ['24']=15}, ['4']={['1']=7.5, ['3']=12, ['6']=15, ['12']=6, ['24']=12}, ['5']={['1']=6, ['3']=10, ['6']=12, ['12']=5, ['24']=10}, ['6']={['1']=4.5, ['3']=8, ['6']=9, ['12']=4, ['24']=8}, ['7']={['1']=3, ['3']=6, ['6']=6, ['12']=3, ['24']=6}, ['8']={['1']=2, ['3']=4, ['6']=4, ['12']=2, ['24']=4}, ['9']={['1']=1, ['3']=2, ['6']=2, ['12']=1, ['24']=2}, ['10']={['1']=0.5, ['3']=1, ['6']=1, ['12']=0, ['24']=1}, ['11']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['12']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['13']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['14']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['15']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['16']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['17']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['18']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['19']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['20']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['21']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['22']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['23']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['24']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['25']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['26']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['27']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['28']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['29']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['30']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['31']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['32']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['33']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['34']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['35']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['36']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['37']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['38']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['39']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['40']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['41']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['42']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['43']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['44']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['45']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['46']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['47']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['48']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['49']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['50']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['51']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['52']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['53']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['54']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['55']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['56']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['57']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['58']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['59']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['60']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['61']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['62']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['63']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['64']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['65']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['66']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['67']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['68']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['69']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['70']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['71']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['72']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['73']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['74']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['75']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, ['76']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, NC={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, Ret={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, DSQ={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, EX={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, DNS={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, C={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, WD={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}, [' ']={['1']=0, ['3']=0, ['6']=0, ['12']=0, ['24']=0}}
        local GTWCE_extra_points_system = {P=1, F=0}
        local GTWCE_color_system = {['1']=colors['gold'], ['2']=colors['silver'], ['3']=colors['bronze'], ['4']=colors['green'], ['5']=colors['green'], ['6']=colors['green'], ['7']=colors['green'], ['8']=colors['green'], ['9']=colors['green'], ['10']=colors['green'], ['11']=colors['dark_blue'], ['12']=colors['dark_blue'], ['13']=colors['dark_blue'], ['14']=colors['dark_blue'], ['15']=colors['dark_blue'], ['16']=colors['dark_blue'], ['17']=colors['dark_blue'], ['18']=colors['dark_blue'], ['19']=colors['dark_blue'], ['20']=colors['dark_blue'], ['21']=colors['dark_blue'], ['22']=colors['dark_blue'], ['23']=colors['dark_blue'], ['24']=colors['dark_blue'], ['25']=colors['dark_blue'], ['26']=colors['dark_blue'], ['27']=colors['dark_blue'], ['28']=colors['dark_blue'], ['29']=colors['dark_blue'], ['30']=colors['dark_blue'], ['31']=colors['dark_blue'], ['32']=colors['dark_blue'], ['33']=colors['dark_blue'], ['34']=colors['dark_blue'], ['35']=colors['dark_blue'], ['36']=colors['dark_blue'], ['37']=colors['dark_blue'], ['38']=colors['dark_blue'], ['39']=colors['dark_blue'], ['40']=colors['dark_blue'], ['41']=colors['dark_blue'], ['42']=colors['dark_blue'], ['43']=colors['dark_blue'], ['44']=colors['dark_blue'], ['45']=colors['dark_blue'], ['46']=colors['dark_blue'], ['47']=colors['dark_blue'], ['48']=colors['dark_blue'], ['49']=colors['dark_blue'], ['50']=colors['dark_blue'], ['51']=colors['dark_blue'], ['52']=colors['dark_blue'], ['53']=colors['dark_blue'], ['54']=colors['dark_blue'], ['55']=colors['dark_blue'], ['56']=colors['dark_blue'], ['57']=colors['dark_blue'], ['58']=colors['dark_blue'], ['59']=colors['dark_blue'], ['60']=colors['dark_blue'], ['61']=colors['dark_blue'], ['62']=colors['dark_blue'], ['63']=colors['dark_blue'], ['64']=colors['dark_blue'], ['65']=colors['dark_blue'], ['66']=colors['dark_blue'], ['67']=colors['dark_blue'], ['68']=colors['dark_blue'], ['69']=colors['dark_blue'], ['70']=colors['dark_blue'], ['71']=colors['dark_blue'], ['72']=colors['dark_blue'], ['73']=colors['dark_blue'], ['74']=colors['dark_blue'], ['75']=colors['dark_blue'], ['76']=colors['dark_blue'], NC=colors['dark_blue'], Ret=colors['purple'], DSQ=colors['black'], EX=colors['black'], DNS=colors['white'], C=colors['white'], WD=colors['white'], [' ']=colors['empty']}
        local GTWCE_display_system = {['1']='1', ['2']='2', ['3']='3', ['4']='4', ['5']='5', ['6']='6', ['7']='7', ['8']='8', ['9']='9', ['10']='10', ['11']='11', ['12']='12', ['13']='13', ['14']='14', ['15']='15', ['16']='16', ['17']='17', ['18']='18', ['19']='19', ['20']='20', ['21']='21', ['22']='22', ['23']='23', ['24']='24', ['25']='25', ['26']='26', ['27']='27', ['28']='28', ['29']='29', ['30']='30', ['31']='31', ['32']='32', ['33']='33', ['34']='34', ['35']='35', ['36']='36', ['37']='37', ['38']='38', ['39']='39', ['40']='40', ['41']='41', ['42']='42', ['43']='43', ['44']='44', ['45']='45', ['46']='46', ['47']='47', ['48']='48', ['49']='49', ['50']='50', ['51']='51', ['52']='52', ['53']='53', ['54']='54', ['55']='55', ['56']='56', ['57']='57', ['58']='58', ['59']='59', ['60']='60', ['61']='61', ['62']='62', ['63']='63', ['64']='64', ['65']='65', ['66']='66', ['67']='67', ['68']='68', ['69']='69', ['70']='70', ['71']='71', ['72']='72', ['73']='73', ['74']='74', ['75']='75', ['76']='76', NC='NC', Ret='Ret', DSQ='DSQ', EX='EX', DNS='DNS', C='C', WD='WD', [' ']='', P='P', F='F'}
        local GTWCE_classification = {'1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59', '60', '61', '62', '63', '64', '65', '66', '67', '68', '69', '70', 'NC', 'Ret', 'DSQ', 'EX', 'DNS', 'C', 'WD', ' '}
        -- points
        local points = calculate(championship, rlengths, {}, results, {}, GTWCE_points_system, GTWCE_extra_points_system)
        -- positions
        local positions = classify(championship, results, points, GTWCE_classification)
        -- table
        local wikitable = convey(championship, races, subraces, {}, drivers, {}, teams, {}, stints, results, {}, points, {}, positions, {}, GTWCE_points_system, GTWCE_extra_points_system, GTWCE_color_system, GTWCE_display_system, sources)
        return wikitable
    end        
    ---- MotoGP
    local function MOTOGP(championship, races, drivers, teams, manufacturers, stints, results, sources)
        -- points system
        ---- current points system
        local MOTOGP_points_system = {['1']=25, ['2']=20, ['3']=16, ['4']=13, ['5']=11, ['6']=10, ['7']=9, ['8']=8, ['9']=7, ['10']=6, ['11']=5, ['12']=4, ['13']=3, ['14']=2, ['15']=1, ['16']=0, ['17']=0, ['18']=0, ['19']=0, ['20']=0, ['21']=0, ['22']=0, ['23']=0, ['24']=0, ['25']=0, ['26']=0, ['27']=0, ['28']=0, ['29']=0, ['30']=0, NC=0, Ret=0, DNQ=0, DNPQ=0, DSQ=0, DNS=0, WD=0, DNP=0, DNA=0, EX=0, [' ']=0}
        local MOTOGP_sprint_points_system = {['1']=12, ['2']=9, ['3']=7, ['4']=6, ['5']=5, ['6']=4, ['7']=3, ['8']=2, ['9']=1, P=0, F=0}
        local MOTOGP_color_system = {['1']=colors['gold'], ['2']=colors['silver'], ['3']=colors['bronze'], ['4']=colors['green'], ['5']=colors['green'], ['6']=colors['green'], ['7']=colors['green'], ['8']=colors['green'], ['9']=colors['green'], ['10']=colors['green'], ['11']=colors['green'], ['12']=colors['green'], ['13']=colors['green'], ['14']=colors['green'], ['15']=colors['green'], ['16']=colors['dark_blue'], ['17']=colors['dark_blue'], ['18']=colors['dark_blue'], ['19']=colors['dark_blue'], ['20']=colors['dark_blue'], ['21']=colors['dark_blue'], ['22']=colors['dark_blue'], ['23']=colors['dark_blue'], ['24']=colors['dark_blue'], ['25']=colors['dark_blue'], ['26']=colors['dark_blue'], ['27']=colors['dark_blue'], ['28']=colors['dark_blue'], ['29']=colors['dark_blue'], ['30']=colors['dark_blue'], NC=colors['dark_blue'], Ret=colors['purple'], DNQ=colors['red'], DNPQ=colors['red'], DSQ=colors['black'], DNS=colors['white'], WD=colors['white'], C=colors['white'], DNP=colors['blank'], DNA=colors['blank'], EX=colors['blank'], [' ']=colors['empty']}
        local MOTOGP_display_system = {['1']='1', ['2']='2', ['3']='3', ['4']='4', ['5']='5', ['6']='6', ['7']='7', ['8']='8', ['9']='9', ['10']='10', ['11']='11', ['12']='12', ['13']='13', ['14']='14', ['15']='15', ['16']='16', ['17']='17', ['18']='18', ['19']='19', ['20']='20', ['21']='21', ['22']='22', ['23']='23', ['24']='24', ['25']='25', ['26']='26', ['27']='27', ['28']='28', ['29']='29', ['30']='30', NC='NC', Ret='Ret', DNQ='DNQ', DNPQ='DNPQ', DSQ='DSQ', DNS='DNS', WD='WD', C='C', DNP='DNP', DNA='DNA', EX='EX', [' ']='', P='P', F='F'}
        local MOTOGP_classification = {'1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', 'NC', 'Ret', 'DNQ', 'DNPQ', 'DSQ', 'DNS', 'WD', 'C', 'DNP', 'DNA', 'EX', ' '}
        -- points
        local points = calculate(championship, {}, {}, results, {}, MOTOGP_points_system, MOTOGP_sprint_points_system)
        -- positions
        local positions = classify(championship, results, points, MOTOGP_classification)
        -- table
        local wikitable = convey(championship, races, {}, {}, drivers, rookies, teams, manufacturers, stints, results, {}, points, {}, positions, {}, MOTOGP_points_system, MOTOGP_sprint_points_system, MOTOGP_color_system, MOTOGP_display_system, sources)
        return wikitable
    end
    ---- FE
    local function FE(championship, races, subraces, drivers, results, sources)
        local FE_points_system = {['1']=25, ['2']=18, ['3']=15, ['4']=12, ['5']=10, ['6']=8, ['7']=6, ['8']=4, ['9']=2, ['10']=1, ['11']=0, ['12']=0, ['13']=0, ['14']=0, ['15']=0, ['16']=0, ['17']=0, ['18']=0, ['19']=0, ['20']=0, ['21']=0, ['22']=0, ['23']=0, ['24']=0, NC=0, Ret=0, DNQ=0, DNPQ=0, DSQ=0, DNS=0, WD=0, C=0, DNP=0, DNA=0, EX=0, [' ']=0}
        local FE_extra_points_system = {P=3, F=1}
        local FE_color_system = {['1']=colors['gold'], ['2']=colors['silver'], ['3']=colors['bronze'], ['4']=colors['green'], ['5']=colors['green'], ['6']=colors['green'], ['7']=colors['green'], ['8']=colors['green'], ['9']=colors['green'], ['10']=colors['green'], ['11']=colors['dark_blue'], ['12']=colors['dark_blue'], ['13']=colors['dark_blue'], ['14']=colors['dark_blue'], ['15']=colors['dark_blue'], ['16']=colors['dark_blue'], ['17']=colors['dark_blue'], ['18']=colors['dark_blue'], ['19']=colors['dark_blue'], ['20']=colors['dark_blue'], ['21']=colors['dark_blue'], ['22']=colors['dark_blue'], ['23']=colors['dark_blue'], ['24']=colors['dark_blue'], NC=colors['dark_blue'], Ret=colors['purple'], DNQ=colors['red'], DNPQ=colors['red'], DSQ=colors['black'], DNS=colors['white'], WD=colors['white'], C=colors['white'], DNP=colors['blank'], DNA=colors['blank'], EX=colors['blank'], [' ']=colors['empty']}
        local FE_display_system = {['1']='1', ['2']='2', ['3']='3', ['4']='4', ['5']='5', ['6']='6', ['7']='7', ['8']='8', ['9']='9', ['10']='10', ['11']='11', ['12']='12', ['13']='13', ['14']='14', ['15']='15', ['16']='16', ['17']='17', ['18']='18', ['19']='19', ['20']='20', ['21']='21', ['22']='22', ['23']='23', ['24']='24', NC='NC', Ret='Ret', DNQ='DNQ', DNPQ='DNPQ', DSQ='DSQ', DNS='DNS', WD='WD', C='C', DNP='DNP', DNA='DNA', EX='EX', [' ']='', P="'''", F="''"}
        local FE_classification = {'1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', 'NC', 'Ret', 'DNQ', 'DNPQ', 'DSQ', 'DNS', 'WD', 'C', 'DNP', 'DNA', 'EX', ' '}
        -- points
        local points = calculate(championship, {}, {}, results, {}, FE_points_system, FE_extra_points_system)
        -- positions
        local positions = classify(championship, results, points, FE_classification)
        -- table
        local wikitable = convey(championship, races, subraces, {}, drivers, {}, {}, {}, {}, results, {}, points, {}, positions, {}, FE_points_system, FE_extra_points_system, FE_color_system, FE_display_system, sources)
        return wikitable
    end
    ---- WSBK
    ---- NASCAR
    -- display
    if championship == 'F1' then
        return F1(championship, races, rdistances, drivers, results, sources)
    elseif championship == 'INDYCAR' then
        return INDYCAR(championship, races, subraces, drivers, rookies, results, penalties, sources)
    elseif championship == 'WRC' then
        return WRC(championship, races, drivers, results, sources)
    elseif championship == 'WEC' then
        return WEC(championship, races, rlengths, drivers, teams, stints, results, sources)
    elseif championship == 'IMSA' then
        return IMSA(championship, races, drivers, results, auxresults, sources)
    elseif championship == 'GTWCE' then
        return GTWCE(championship, races, rlengths, subraces, drivers, teams, stints, results, sources)
    elseif championship == 'MOTOGP' then
        return MOTOGP(championship, races, drivers, teams, manufacturers, stints, results, sources)
    elseif championship == 'FE' then
        return FE(championship, races, subraces, drivers, results, sources)
    else
        local points = calculate(nil, {}, {}, results, penalties, ex_main_points_system, ex_side_points_system)
        local positions = classify(nil, results, points, ex_classification)
        local wikitable = convey(nil, races, subraces, {}, drivers, rookies, teams, manufacturers, stints, results, penalties, points, {}, positions, {}, ex_main_points_system, ex_side_points_system, ex_color_system, ex_display_system, args['sources'])
        return wikitable
    end
end

return p