Module:formatting: Difference between revisions

From Laenkea
Jump to navigation Jump to search
(Created page with "local export function export.wrap_text(text, language, face) local faces = mw.loadData("Module:formatting/data")["faces"] local data = faces[face] or faces["nil"] local function compile_tags() local tags = {} if data.class and data.class ~= "" then table.insert(tags, 'class="' .. data.class .. '"') end if language then table.insert(tags, 'lang="' .. language.code .. '"') end end return (data.prefix or "") .. "<" .. data.tag .. " " .. compile_tags()...")
 
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
local export
local export = {}


function export.wrap_text(text, language, face)
function export.wrap_face(text, language, face)
local faces = mw.loadData("Module:formatting/data")["faces"]
local faces = mw.loadData("Module:formatting/data")["faces"]
local data = faces[face] or faces["nil"]
local data = faces[face] or faces["nil"]
Line 12: Line 12:
table.insert(tags, 'lang="' .. language.code .. '"')
table.insert(tags, 'lang="' .. language.code .. '"')
end
end
return table.concat(tags, " ")
end
end
return (data.prefix or "") .. "<" .. data.tag .. " " .. compile_tags() .. ">" .. text .. "</" .. data.tag .. ">"
return (data.prefix or "") .. "<" .. data.tag .. " " .. compile_tags() .. ">" .. text .. "</" .. data.tag .. ">"

Latest revision as of 14:25, 6 August 2023

Documentation for this module may be created at Module:formatting/documentation

local export = {}

function export.wrap_face(text, language, face)
	local faces = mw.loadData("Module:formatting/data")["faces"]
	local data = faces[face] or faces["nil"]
	local function compile_tags()
		local tags = {}
		if data.class and data.class ~= "" then
			table.insert(tags, 'class="' .. data.class .. '"')
		end
		if language then
			table.insert(tags, 'lang="' .. language.code .. '"')
		end
		return table.concat(tags, " ")
	end
	return (data.prefix or "") .. "<" .. data.tag .. " " .. compile_tags() .. ">" .. text .. "</" .. data.tag .. ">"
end

return export