Jump to content

Module:Navbox with nowrap lists

Frá Wikipedia, hin frælsa alfrøðin

Tú kanst upprætta kunningarsíðu um hetta modulið á Module:Navbox with nowrap lists/doc

-- Inspired by [[Module:Team roster navbox]]
local p = {}

local Navbox = require('Module:Navbox')

local function nowrapList(list)
	local listLines = {}
	for line in (list .. '\n'):gmatch('([^\n]*)\n') do
		table.insert(listLines, (line:gsub('^([*:;]+[ \t]*)(.-)$', function(lineStart, lineContent)
			if lineContent:match('^<span class="nowrap">') then
				return lineStart .. lineContent
			else
				return lineStart .. '<span class="nowrap">' .. lineContent .. '</span>'
			end
		end)))
	end
	return table.concat(listLines, '\n')
end

function p.navbox(frame)
	local args = frame:getParent().args

	for k,v in pairs(args) do
		if type(k) == 'string' and (k:match('^list[0-9]') or k:match('^above') or k:match('^below')) then
			args[k] = nowrapList(v)
		end
	end
	return Navbox._navbox(args)

end

return p