<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3AHangul</id>
	<title>Module:Hangul - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3AHangul"/>
	<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Hangul&amp;action=history"/>
	<updated>2026-05-24T20:58:17Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://stockhub.co/index.php?title=Module:Hangul&amp;diff=136445&amp;oldid=prev</id>
		<title>imported&gt;Erutuon: mw.loadData not really needed here</title>
		<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Hangul&amp;diff=136445&amp;oldid=prev"/>
		<updated>2021-08-16T03:59:11Z</updated>

		<summary type="html">&lt;p&gt;mw.loadData not really needed here&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local p = {}&lt;br /&gt;
&lt;br /&gt;
local data = require &amp;#039;Module:Hangul/data&amp;#039;&lt;br /&gt;
&lt;br /&gt;
---- From [[wikt:Module:ko-hangul]&lt;br /&gt;
 &lt;br /&gt;
-- Given the &amp;quot;syllable index&amp;quot; of a precomposed Hangul syllable (see&lt;br /&gt;
-- above), returns &amp;quot;indices&amp;quot; representing the three constituent jamo&lt;br /&gt;
-- (&amp;quot;lead&amp;quot;, i.e. initial consonant; &amp;quot;vowel&amp;quot;; and &amp;quot;tail&amp;quot;, i.e. final&lt;br /&gt;
-- consonant, except that zero denotes the absence of a final consonant).&lt;br /&gt;
local function syllableIndex2JamoIndices(syllableIndex)&lt;br /&gt;
    local lIndex = math.floor(syllableIndex / 588)&lt;br /&gt;
    local vIndex = math.floor((syllableIndex % 588) / 28)&lt;br /&gt;
    local tIndex = syllableIndex % 28&lt;br /&gt;
 &lt;br /&gt;
    return lIndex, vIndex, tIndex&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
local tocodepoint = mw.ustring.codepoint&lt;br /&gt;
&lt;br /&gt;
local function indexof(arr, val)&lt;br /&gt;
	for i, v in ipairs(arr) do&lt;br /&gt;
		if v == val then&lt;br /&gt;
			return i&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return -1&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function get_name(char)&lt;br /&gt;
	local codepoint = tocodepoint(char)&lt;br /&gt;
	&lt;br /&gt;
	-- Hangul Compatibility Jamo block&lt;br /&gt;
	if 0x3130 &amp;lt;= codepoint and codepoint &amp;lt;= 0x318F then&lt;br /&gt;
		return (&amp;#039;U+%X: HANGUL LETTER %s&amp;#039;):format(codepoint, data.names[codepoint - 0x3130])&lt;br /&gt;
	&lt;br /&gt;
	-- Hangul Syllables block&lt;br /&gt;
	-- From [[wikt:Module:Unicode data]].&lt;br /&gt;
	-- Cheaper to derive names from decomposed form of syllable?&lt;br /&gt;
	elseif 0xAC00 &amp;lt;= codepoint and codepoint &amp;lt;= 0xD7A3 then&lt;br /&gt;
		local li, vi, ti = syllableIndex2JamoIndices(codepoint - 0xAC00)&lt;br /&gt;
		return (&amp;quot;U+%X: HANGUL SYLLABLE %s%s%s&amp;quot;):format(&lt;br /&gt;
			codepoint, data.leads[li], data.vowels[vi], data.trails[ti])&lt;br /&gt;
	&lt;br /&gt;
	else&lt;br /&gt;
		error((&amp;#039;No name for U+%X found.&amp;#039;):format(codepoint))&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function get_anchor(index)&lt;br /&gt;
	return string.char((&amp;#039;a&amp;#039;):byte() + index - 1):rep(2)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function diag_split_header(column_text, row_text)&lt;br /&gt;
	return mw.getCurrentFrame():expandTemplate{&lt;br /&gt;
		title = &amp;#039;diagonal_split_header&amp;#039;,&lt;br /&gt;
		args = { column_text, row_text },&lt;br /&gt;
	}&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function syllables_by_initial(initial)&lt;br /&gt;
	local codepoint = mw.ustring.codepoint(initial)&lt;br /&gt;
	if not (0x1100 &amp;lt;= codepoint and codepoint &amp;lt;= 0x1112) then&lt;br /&gt;
		error(&amp;#039;Incorrect initial &amp;#039; .. initial .. &amp;#039;. Should be between U+1100 and U+1112.&amp;#039;)&lt;br /&gt;
	end&lt;br /&gt;
	local initial_index = indexof(data.initials, initial)&lt;br /&gt;
	&lt;br /&gt;
	local output = {}&lt;br /&gt;
	local i = 0&lt;br /&gt;
	local function push(text)&lt;br /&gt;
		i = i + 1&lt;br /&gt;
		output[i] = text&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	push(&lt;br /&gt;
([[&lt;br /&gt;
{| class=&amp;quot;wikitable collapsible collapsed nowrap&amp;quot;&lt;br /&gt;
|+ id=&amp;quot;%s&amp;quot; | Initial&amp;amp;nbsp;&amp;lt;span lang=&amp;quot;ko&amp;quot;&amp;gt;%s&amp;lt;/span&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! %s]]):format(&lt;br /&gt;
	get_anchor(initial_index),&lt;br /&gt;
	data.independent_initials[initial_index],&lt;br /&gt;
	diag_split_header(&amp;#039;Medial&amp;#039;, &amp;#039;Final&amp;#039;))) -- initial jamo&lt;br /&gt;
&lt;br /&gt;
	for _, final in ipairs(data.independent_finals) do&lt;br /&gt;
		push((&amp;#039;! title=&amp;quot;%s&amp;quot; | &amp;lt;span lang=&amp;quot;ko&amp;quot;&amp;gt;%s&amp;lt;/span&amp;gt;&amp;#039;)&lt;br /&gt;
			:format(final ~= &amp;#039;&amp;#039; and get_name(final) or &amp;#039;&amp;#039;, final))&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	for i, medial in ipairs(data.medials) do&lt;br /&gt;
		push(&amp;#039;|- lang=&amp;quot;ko&amp;quot;&amp;#039;)&lt;br /&gt;
		local independent_medial = data.independent_medials[i]&lt;br /&gt;
		push((&amp;#039;! scope=&amp;quot;row&amp;quot; title=&amp;quot;%s&amp;quot; | %s&amp;#039;)&lt;br /&gt;
			:format(get_name(independent_medial), independent_medial))&lt;br /&gt;
		for _, final in ipairs(data.finals) do&lt;br /&gt;
			push((&amp;#039;| %s%s%s&amp;#039;):format(initial, medial, final))&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	push(&amp;#039;|}&amp;#039;)&lt;br /&gt;
	&lt;br /&gt;
	output = table.concat(output, &amp;#039;\n&amp;#039;)&lt;br /&gt;
	output = mw.ustring.toNFC(output)&lt;br /&gt;
	output = mw.ustring.gsub( -- Add names of syllable codepoints.&lt;br /&gt;
		output,&lt;br /&gt;
		&amp;#039;[가-힣]&amp;#039;, -- [[Hangul Syllables]] block (U+AC00-D7AF)&lt;br /&gt;
		function (syllable)&lt;br /&gt;
			return (&amp;#039;title=&amp;quot;%s&amp;quot; | %s&amp;#039;):format(get_name(syllable), syllable)&lt;br /&gt;
		end)&lt;br /&gt;
	&lt;br /&gt;
	-- Check for consecutive span tags.&lt;br /&gt;
	-- output:gsub(&amp;#039;&amp;lt;span[^&amp;gt;]+&amp;gt;[^&amp;lt;]*&amp;lt;/span&amp;gt;&amp;lt;span[^&amp;gt;]+&amp;gt;[^&amp;lt;]*&amp;lt;/span&amp;gt;&amp;#039;, mw.log)&lt;br /&gt;
	&lt;br /&gt;
	return output&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.syllables_by_initial(frame)&lt;br /&gt;
	local initial = frame.args[1] or &amp;#039;ᄀ&amp;#039;&lt;br /&gt;
	return syllables_by_initial(initial)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.all_syllables(frame)&lt;br /&gt;
	local tables = {}&lt;br /&gt;
	for i, initial in ipairs(data.initials) do&lt;br /&gt;
		tables[i] = syllables_by_initial(initial)&lt;br /&gt;
	end&lt;br /&gt;
	return table.concat(tables, &amp;#039;\n&amp;#039;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.TOC(frame)&lt;br /&gt;
	local output = {}&lt;br /&gt;
	for i, initial in ipairs(data.independent_initials) do&lt;br /&gt;
		table.insert(output, (&amp;#039;| [[#%s|%s]]&amp;#039;):format(get_anchor(i), initial))&lt;br /&gt;
	end&lt;br /&gt;
	table.insert(output, 1, &amp;#039;{| class=&amp;quot;wikitable&amp;quot; lang=&amp;quot;ko&amp;quot; style=&amp;quot;width: 96px; height: 10px;&amp;quot;&amp;#039;)&lt;br /&gt;
	table.insert(output, &amp;#039;|}&amp;#039;)&lt;br /&gt;
	return table.concat(output, &amp;#039;\n&amp;#039;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>imported&gt;Erutuon</name></author>
	</entry>
</feed>