Module:Aligned table: Difference between revisions

    No edit summary
    (colstyle and colclass and colalign and colnowrap)
    Line 1: Line 1:
    -- This module implements {{aligned table}}
    -- This module implements {{aligned table}}
    local p = {}
    local p = {}
    local function isnotempty(s)
    return s and s:match( '^%s*(.-)%s*$' ) ~= ''
    end


    function p.table(frame)
    function p.table(frame)
    Line 39: Line 43:
    colclass[ i ] = colclass[ i ] or ''
    colclass[ i ] = colclass[ i ] or ''
    colstyle[ i ] = colstyle[ i ] or ''
    colstyle[ i ] = colstyle[ i ] or ''
    if args['align' .. tostring(i)] then
    if isnotempty(args['colalign' .. tostring(i)]) then
    colstyle[ i ] = 'text-align:' .. args['colalign' .. tostring(i)] .. ';' .. colstyle[ i ]
    elseif isnotempty(args['align' .. tostring(i)]) then
    colstyle[ i ] = 'text-align:' .. args['align' .. tostring(i)] .. ';' .. colstyle[ i ]
    colstyle[ i ] = 'text-align:' .. args['align' .. tostring(i)] .. ';' .. colstyle[ i ]
    end
    end
    if args['nowrap' .. tostring(i)] and args['nowrap' .. tostring(i)] ~= '' then
    if isnotempty(args['colnowrap' .. tostring(i)]) then
    colstyle[ i ] = 'white-space:nowrap;' .. colstyle[ i ]
    elseif isnotempty(args['nowrap' .. tostring(i)]) then
    colstyle[ i ] = 'white-space:nowrap;' .. colstyle[ i ]
    colstyle[ i ] = 'white-space:nowrap;' .. colstyle[ i ]
    end
    end
    if args['style' .. tostring(i)] then
    if isnotempty(args['colstyle' .. tostring(i)]) then
    colstyle[ i ] = colstyle[ i ] .. args['colstyle' .. tostring(i)]
    elseif isnotempty(args['style' .. tostring(i)]) then
    colstyle[ i ] = colstyle[ i ] .. args['style' .. tostring(i)]
    colstyle[ i ] = colstyle[ i ] .. args['style' .. tostring(i)]
    end
    end
    if args['class' .. tostring(i)] then
    if isnotempty(args['colclass' .. tostring(i)]) then
    colclass[ i ] =  args['colclass' .. tostring(i)]
    elseif isnotempty(args['class' .. tostring(i)]) then
    colclass[ i ] =  args['class' .. tostring(i)]
    colclass[ i ] =  args['class' .. tostring(i)]
    end
    end