Перейти до вмісту

Модуль:Make fake heading/пісочниця

Матеріал з Вікіпедії — вільної енциклопедії.
{{i}} Документація модуля[створити]
local function is_set (checked_value)
	if checked_value and checked_value ~= '' then
		return true
	else
		return false
	end	
end


local function main (frame)
	local input_text = frame.args[1]
	local success
	
	for level = 1, 7 do
		if input_text:find('<h' .. level, 1) then
			local class = is_set(frame.args['class_h' .. level]) and (' ' .. frame.args['class_h' .. level]) or ''
			local style = is_set(frame.args['style_h' .. level]) and (' style="' .. frame.args['style_h' .. level] .. '"') or ''
			
			input_text, success = string.gsub(input_text:gsub('<h' .. level, '<div class="mw-heading mw-heading' .. level .. class .. '"' .. style), '</h' .. level, '</div')
		end
	end
	
	return input_text
end

return {
	main = main
};