Interested Article - Cyrlat

Документация

Реализация {{ кирлат }} .

local p = {} -- p stands for package

function _color (sym)
	if mw.ustring.match(sym, '[Ѐ-҄҇-ԯᲀ-ᲈᴫᵸⷠ-ⷿꙀ-ꚟ︮-︯]') then
		return 'blue' -- cyrillic
	elseif mw.ustring.match(sym, '[A-Za-zªºÀ-ÖØ-öø-ʸˠ-ˤᴀ-ᴥᴬ-ᵜᵢ-ᵥᵫ-ᵷᵹ-ᶾḀ-ỿⁱⁿₐ-ₜℲⅎⅠ-ↈⱠ-ⱿꜢ-ꞇꞋ-ꞿꟂ-ꟊꟵ-ꟿꬰ-ꭚꭜ-ꭤꭦ-ꭩff-stA-Za-z]')then
		return 'red' -- latin
	else
		return 'black' -- other symbols
	end
end

function p.color (frame)
	local str = frame:getParent().args[1] or ''
	local results = {}
	for i = 1, mw.ustring.len(str) do
		local sym = mw.ustring.sub(str, i, i)
		table.insert(results, '<span style="color:' .. _color(sym) .. '">' .. sym .. '</span>')
	end
	return table.concat(results)
end

return p
Источник —

Same as Cyrlat