Jump to content

विभाग:Navbox with nowrap lists

Page semi-protected
विकिपीडिया, मुक्‍त ज्ञानकोशातून
-- 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