Jump to content

Module:Ko-utils

Permanently protected module
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Grapesurgeon (talk | contribs) at 20:56, 17 April 2025 (fix?). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
local p = {}
local find = mw.ustring.find
local get_args = require('Module:Arguments').getArgs

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

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

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

return p