Module:ModularCSS/UserLinks

--[=[ List format:
 * Group1
 * Optional group style (todo)
 * User1
 * Optional user style (todo)
 * User2

--]=]
 * Group2
 * User3
 * User4

local BASE_STYLE = [====[ /***** ModularCSS/UserLinks *****/ /* todo: add link styling */ [=[.Wall .edited-by a.subtle[href$="Message_Wall:$USER"]:after]=] { content: "($GROUP)" !important; } ]====]

local CHUNK_CAPT = "%[=%[(.-)%]=%]"

return { page = "Project:User links", main = function(parsed) local styles = {} local piles = {} -- create piles for group in pairs(parsed) do           local GRP_STYLE = BASE_STYLE:gsub("$GROUP", group) local grp_pile = {} for user in pairs(group) do               local pile_n = 0 for chunk in GRP_STYLE:gmatch(CHUNK_CAPT) do                   pile_n = pile_n + 1 grp_pile[pile_n] = grp_pile[pile_n] or {} table.insert(grp_pile[pile_n], ( chunk:gsub("$USER", user) )) end end table.insert(styles, GRP_STYLE) table.insert(piles, grp_pile) end -- compile local compiled = "" local pile_n = 0 for _,style in pairs(styles) do           compiled = compiled .. style:gsub(CHUNK_CAPT, function                   local compiled = ""                    pile_n = pile_n + 1                    for _,grp_pile in pairs(piles) do                        local pile = grp_pile[pile_n]                        for _,chunk in pairs(pile) do                            compiled = compiled .. chunk .. ",\n"                        end                    end                    return compiled:sub(1,-3)                end) end return compiled end }