Module:Main article

-- local p = {}

function p.main(frame) local args = frame:getParent.args local ret = mw.html.create('div') :addClass('seealso') local params = {} local ttl = 0 for _, v in ipairs(args) do       ttl = ttl + 1 table.insert(params,v) end ret:wikitext('Main article' .. (#params > 1 and 's' or '') .. ': ' ) local function link(article) if article:find('#',1,true) then local article_t = mw.text.split(article,'#') article_t = table.concat(article_t,' § ') article = article..article_t end return ..article.. end for i, v in ipairs(params) do       if i 1 then ret:wikitext(link(v)) elseif i == ttl then if ttl == 1 then ret:wikitext(link(v)) else ret:wikitext(' and '..link(v)) end end if i 2 then ret:wikitext(', ') end end ret:wikitext('.') return ret end

return p