Module:User:Babr/Sandbox2

Hello, you have come here looking for the meaning of the word Module:User:Babr/Sandbox2. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:User:Babr/Sandbox2, but we will also tell you about its etymology, its characteristics and you will know how to say Module:User:Babr/Sandbox2 in singular and plural. Everything you need to know about the word Module:User:Babr/Sandbox2 you have here. The definition of the word Module:User:Babr/Sandbox2 will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:User:Babr/Sandbox2, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.


local export = {}

function export.show(frame)
	local pageContent = mw.title.new("User:Babr/Palette.css"):getContent()

	local lightMode = true;
	local lightModeData = {}
	local darkModeData = {}
	local seenVariables = {} -- In order to maintain the order.

	local output = {
[=[{| class="palette-table wikitable"
|+Examples of palette variables in light and dark mode
|-
!scope="col"| Variable name
!scope="col"| Light mode
!scope="col"| Dark mode
|-"
]=]}
	for line in pageContent:gmatch("*") do
		-- Hack to check whether we've reached the dark mode styles.
		if line == "@media screen {" then
			lightMode = false;
		end
		
		local definedVariable = line:match("--wikt%-palette%-+")
		if definedVariable then
			if lightMode then
				table.insert(seenVariables, definedVariable)
				lightModeData = line:match("#+")
			else
				darkModeData = line:match("#+")
			end
		end
	end
	
	for _, var in ipairs(seenVariables) do
		table.insert(output, "|<code>" .. var .. "</code>")
		table.insert(output, "||style=\"background-color:" .. lightModeData .. "\"|<span class=\"palette-highlight\">" .. lightModeData .. "</span>")
		table.insert(output, "||style=\"background-color:" .. darkModeData .. "\"|<span class=\"palette-highlight\">" .. darkModeData .. "</span>")
		table.insert(output, "\n|-\n")
	end

	table.insert(output, "\n|}")
	table.insert(output, frame:extensionTag("templatestyles", "", {src="Module:palette/styles.css"}))

	return table.concat(output)
end

return export