<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://mywikibiz.com/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://mywikibiz.com/index.php?action=history&amp;feed=atom&amp;title=Module%3AHangul"/>
	<link rel="alternate" type="text/html" href="https://mywikibiz.com/index.php?title=Module:Hangul&amp;action=history"/>
	<updated>2026-06-15T16:07:52Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.3</generator>
	<entry>
		<id>https://mywikibiz.com/index.php?title=Module:Hangul&amp;diff=471882&amp;oldid=prev</id>
		<title>Zoran: Pywikibot 6.4.0</title>
		<link rel="alternate" type="text/html" href="https://mywikibiz.com/index.php?title=Module:Hangul&amp;diff=471882&amp;oldid=prev"/>
		<updated>2021-07-15T21:54:58Z</updated>

		<summary type="html">&lt;p&gt;Pywikibot 6.4.0&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 = mw.loadData 'Module:Hangul/data'&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 ('U+%X: HANGUL LETTER %s'):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(('No name for U+%X found.'):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(('a'):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 = 'diagonal_split_header',&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('Incorrect initial ' .. initial .. '. Should be between U+1100 and U+1112.')&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; style=&amp;quot;width: 96px; height: 96px;&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('Medial', 'Final'))) -- initial jamo&lt;br /&gt;
&lt;br /&gt;
	for _, final in ipairs(data.independent_finals) do&lt;br /&gt;
		push(('! title=&amp;quot;%s&amp;quot; | &amp;lt;span lang=&amp;quot;ko&amp;quot;&amp;gt;%s&amp;lt;/span&amp;gt;')&lt;br /&gt;
			:format(final ~= '' and get_name(final) or '', final))&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	for i, medial in ipairs(data.medials) do&lt;br /&gt;
		push('|- lang=&amp;quot;ko&amp;quot;')&lt;br /&gt;
		local independent_medial = data.independent_medials[i]&lt;br /&gt;
		push(('! scope=&amp;quot;row&amp;quot; title=&amp;quot;%s&amp;quot; | %s')&lt;br /&gt;
			:format(get_name(independent_medial), independent_medial))&lt;br /&gt;
		for _, final in ipairs(data.finals) do&lt;br /&gt;
			push(('| %s%s%s'):format(initial, medial, final))&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	push('|}')&lt;br /&gt;
	&lt;br /&gt;
	output = table.concat(output, '\n')&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;
		'[가-힣]', -- [[Hangul Syllables]] block (U+AC00-D7AF)&lt;br /&gt;
		function (syllable)&lt;br /&gt;
			return ('title=&amp;quot;%s&amp;quot; | %s'):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;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;', 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 'ᄀ'&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, '\n')&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, ('| [[#%s|%s]]'):format(get_anchor(i), initial))&lt;br /&gt;
	end&lt;br /&gt;
	table.insert(output, 1, '{| class=&amp;quot;wikitable&amp;quot; lang=&amp;quot;ko&amp;quot; style=&amp;quot;width: 96px; height: 10px;&amp;quot;')&lt;br /&gt;
	table.insert(output, '|}')&lt;br /&gt;
	return table.concat(output, '\n')&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Zoran</name></author>
	</entry>
</feed>