Модуль:Кнопка

Материал из SS220 Paradise Wiki (SS13)
Версия от 21:17, 18 мая 2023; Gevron (обсуждение | вклад) (Новая страница: «local p = {} p.keys = function( f ) local args = f if f == mw.getCurrentFrame() then args = f:getParent().args end local keys = {} for _, key in ipairs( args ) do key = mw.text.trim( key ) if key ~= '+' and key:find( '%+' ) then local comboKeys = {} for comboKey in mw.text.gsplit( key, '%s*%+%s*' ) do table.insert( comboKeys, p.key( comboKey ) ) end table.insert( keys, table.concat( comboKeys, ' + ' ) ) else tabl...»)
(разн.) ← Предыдущая версия | Текущая версия (разн.) | Следующая версия → (разн.)
Перейти к навигации Перейти к поиску

Для документации этого модуля может быть создана страница Модуль:Кнопка/док

local p = {}
p.keys = function( f )
	local args = f
	if f == mw.getCurrentFrame() then
		args = f:getParent().args
	end
	local keys = {}
	
	for _, key in ipairs( args ) do
		key = mw.text.trim( key )
		if key ~= '+' and key:find( '%+' ) then
			local comboKeys = {}
			for comboKey in mw.text.gsplit( key, '%s*%+%s*' ) do
				table.insert( comboKeys, p.key( comboKey ) )
			end
			table.insert( keys, table.concat( comboKeys, ' + ' ) )
		else
			table.insert( keys, p.key( key ) )
		end
	end
	
	return table.concat( keys )
end

p.key = function( key )
	if key == '' then
		return ''
	end
	
	local symbols = mw.loadData( 'Модуль:Кнопка/Символы' )
	return '<kbd class="keyboard-key nowrap">' .. ( symbols[key:lower()] or key ) .. '</kbd>'
end
return p