Jump to content

Module:documentation/functions/guoxue-data

From Wiktionary, the free dictionary


return function (title, cats)
	local suffix = title.fullText:match("^Module:mul/guoxue%-data/cjk%-?(.*)$")
	local block
	if suffix == "" then
		block = "CJK Unified Ideographs"
	elseif suffix:find("^%l$") then
		block = "CJK Unified Ideographs Extension " .. suffix:upper()
	elseif suffix == "compat" then
		block = "CJK Compatibility Ideographs"
	elseif suffix == "compat-sup" then
		block = "CJK Compatibility Ideographs Supplement"
	else
		mw.log("Unicode block for " .. title.fullText " not found.")
		return
	end
	
	local block_link = ("[[Appendix:Unicode/%s|%s]]"):format(block, block)
	local start, ending = require("Module:Unicode data").get_block_range(block)
	if not start then
		mw.log("Code point range for the Unicode block " .. tostring(block) .. " not found.")
		return
	end
	
	local sortkey = "|guoxue, " .. suffix
	cats:insert("Data modules" .. sortkey)
	cats:insert("Han script modules" .. sortkey)
	cats:insert("Translingual modules" .. sortkey)
	
	return ("This module contains data on CJK characters in "
		.. "the Unicode block %s (U+%04X–U+%04X) from [https://guoxuedashi.com guoxuedashi.com].")
		:format(block_link, start, ending)
end