Jump to content

Module:Ko-utils

From Wikipedia, the free encyclopedia
local p = {}
local find = mw.ustring.find

-- Decomposes Hangul into jamo
function p.decompose_hangul(text)
	return mw.ustring.gsub(text, "[가-힣]", mw.ustring.toNFD)
end

-- Returns boolean on whether input contains any Hangul text at all
function p.contains_hangul(text)
	local hangul_ranges = "[ᄀ-ᇿ〮〯ㄱ-ㆎ㈀-㈞㉠-㉾ꥠ-꥿가-힣ힰ-퟿]"
	return text ~= nil and text ~= "" and find(text, hangul_ranges)
end

-- Returns boolean on whether input directly contains a Wikipedia reference
function p.contains_reference(text)
	return find(text, "'\"`UNIQ--") or find(text, "-QINU`\"'")
end

return p