Jump to content

Module:sn-utilities

From Wiktionary, the free dictionary


local export = {}

function export.acute_on_all_vowels(frame)
	local word = frame.args[1]
	if not word then
		return ""
	end
	local acute = mw.ustring.char(0x0301)
	return (mw.ustring.gsub(
		mw.ustring.toNFD(word),
		"([AaEeIiOoUu])" .. acute .. "?",
		"%1" .. acute))
end

function export.acute_on_all_but_first_vowel(frame)
	local word = frame.args[1]
	if not word then
		return ""
	end
	local i = 0
	local acute = mw.ustring.char(0x0301)
	return (mw.ustring.gsub(
		mw.ustring.toNFD(word),
		"([AaEeIiOoUu])" .. acute .. "?",
		function(vowel)
			i = i + 1
			if i == 1 then
				return vowel
			else
				return vowel .. acute
			end
		end))
end

return export