Jump to content

Module:Sandbox/Erutuon

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Erutuon (talk | contribs) at 21:30, 19 May 2019 (function for processing Proto-Slavic to remove unnecessary piping in Template:wt). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

local p = {}

local function make_entry_name(word)
	for k, v in pairs {
		["[ÀÁÃĀȀȂ]"] = "A",
		["[àáãāȁȃ]"] = "a",
		["[ÈÉẼĒȄȆ]"] = "E",
		["[èéẽēȅȇ]"] = "e",
		["[ÌÍĨĪȈȊ]"] = "I",
		["[ìíĩīȉȋ]"] = "i",
		["[ÒÓÕŌȌȎŐ]"] = "O",
		["[òóõōȍȏő]"] = "o",
		["[ÙÚŨŪȔȖŰ]"] = "U",
		["[ùúũūȕȗű]"] = "u",
		["[ỲÝỸȲ]"] = "Y",
		["[ỳýỹȳ]"] = "y",
		["Ǭ"] = "Ǫ",
		["ǭ"] = "ǫ",
		["[̀́̃̄̏̑]"]= "",
		["ĭ"] = "ь",
		["ŭ"] = "ъ",
	} do
		word = mw.ustring.gsub(word, k, v)
	end
	return word
end

function p.show(frame)
	local content = mw.title.new "Proto-Slavic":getContent()
	local new_content = content:gsub(
		'{{wt|sla%-pro|([^|}]+)|([^|}]+)}}',
		function (entry, text)
			if make_entry_name(text) == entry then
				return '{{wt|sla-pro|' .. text .. '}}'
			else
				mw.log(entry, text)
			end
		end)
	if content ~= new_content then
		return frame:extensionTag{
			name = "syntaxhighlight",
			content = new_content,
			args = { lang = "lua" },
		}
	end
end

return p