<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://70.231.62.181/index.php?action=history&amp;feed=atom&amp;title=Module%3AUnicode_data%2Fscripts%2Fmake</id>
	<title>Module:Unicode data/scripts/make - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://70.231.62.181/index.php?action=history&amp;feed=atom&amp;title=Module%3AUnicode_data%2Fscripts%2Fmake"/>
	<link rel="alternate" type="text/html" href="http://70.231.62.181/index.php?title=Module:Unicode_data/scripts/make&amp;action=history"/>
	<updated>2026-04-21T09:36:26Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>http://70.231.62.181/index.php?title=Module:Unicode_data/scripts/make&amp;diff=20130113&amp;oldid=prev</id>
		<title>imported&gt;Erutuon: remove separation between variable definition and use</title>
		<link rel="alternate" type="text/html" href="http://70.231.62.181/index.php?title=Module:Unicode_data/scripts/make&amp;diff=20130113&amp;oldid=prev"/>
		<updated>2020-03-11T19:28:30Z</updated>

		<summary type="html">&lt;p&gt;remove separation between variable definition and use&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 Array = require &amp;#039;Module:Array&amp;#039;&lt;br /&gt;
&lt;br /&gt;
local function pattern_escape(str)&lt;br /&gt;
	return (str:gsub(&amp;#039;%p&amp;#039;, &amp;#039;%%%1&amp;#039;))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.make_script_name_to_code(page_name)&lt;br /&gt;
	local property_value_aliases = assert(assert(mw.title.new(page_name)):getContent())&lt;br /&gt;
&lt;br /&gt;
	local script_aliases = property_value_aliases:match(&lt;br /&gt;
		pattern_escape &amp;#039;# Script (sc)&amp;#039;&lt;br /&gt;
		.. &amp;#039;%s+(.-)%s+&amp;#039;&lt;br /&gt;
		.. pattern_escape &amp;#039;# Script_Extensions (scx)&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
	local script_name_to_code = {}&lt;br /&gt;
	&lt;br /&gt;
	for code, name in script_aliases:gmatch &amp;#039;sc%s+;%s+(%a+)%s+;%s+([%a_]+)&amp;#039; do&lt;br /&gt;
		script_name_to_code[name] = code&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return script_name_to_code&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.make_script_data(scripts_txt, property_value_aliases_txt)&lt;br /&gt;
	local script_data = assert(assert(mw.title.new(scripts_txt)):getContent())&lt;br /&gt;
	&lt;br /&gt;
	local script_name_to_code = p.make_script_name_to_code(property_value_aliases_txt)&lt;br /&gt;
	setmetatable(script_name_to_code, { __index = function (self, k)&lt;br /&gt;
		error((&amp;#039;No code for &amp;quot;%s&amp;quot;&amp;#039;):format(k))&lt;br /&gt;
	end })&lt;br /&gt;
	&lt;br /&gt;
	local script_ranges = Array()&lt;br /&gt;
	&lt;br /&gt;
	local prev_codepoint, prev_script_name, prev_script_range&lt;br /&gt;
	for codepoint1, codepoint2, script_name in script_data:gmatch &amp;#039;%f[^\n%z](%x+)%.?%.?(%x*)%s+;%s*([%w_]+)&amp;#039; do&lt;br /&gt;
		codepoint1, codepoint2 = tonumber(codepoint1, 16), tonumber(codepoint2, 16)&lt;br /&gt;
		local script_range&lt;br /&gt;
		if prev_script_range and script_name == prev_script_name and codepoint1 - prev_codepoint == 1 then&lt;br /&gt;
			prev_script_range[2] = codepoint2 or codepoint1&lt;br /&gt;
		else&lt;br /&gt;
			script_range = { codepoint1, codepoint2 or codepoint1, script_name_to_code[script_name] }&lt;br /&gt;
			script_ranges:insert(script_range)&lt;br /&gt;
		end&lt;br /&gt;
		prev_codepoint, prev_script_name, prev_script_range =&lt;br /&gt;
			codepoint2 or codepoint1, script_name, script_range or prev_script_range&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local singles = {}&lt;br /&gt;
	local i = 1&lt;br /&gt;
	&lt;br /&gt;
	while script_ranges[i] do&lt;br /&gt;
		local low, high, script_code = unpack(script_ranges[i])&lt;br /&gt;
		if low == high then&lt;br /&gt;
			singles[low] = script_code&lt;br /&gt;
			script_ranges:remove(i)&lt;br /&gt;
		else&lt;br /&gt;
			i = i + 1&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	script_ranges:sort(&lt;br /&gt;
		function (range1, range2)&lt;br /&gt;
			return range1[1] &amp;lt; range2[1]&lt;br /&gt;
		end)&lt;br /&gt;
	&lt;br /&gt;
	local template = [[&lt;br /&gt;
local data = {&lt;br /&gt;
	singles = {&lt;br /&gt;
...&lt;br /&gt;
	},&lt;br /&gt;
	&lt;br /&gt;
	ranges = {&lt;br /&gt;
...&lt;br /&gt;
	},&lt;br /&gt;
	-- Scripts.txt gives full names; here we consider them aliases to save space.&lt;br /&gt;
	aliases = {&lt;br /&gt;
...&lt;br /&gt;
	},&lt;br /&gt;
}&lt;br /&gt;
]]&lt;br /&gt;
	&lt;br /&gt;
	local printed_ranges = Array()&lt;br /&gt;
	for _, range in ipairs(script_ranges) do&lt;br /&gt;
		local low, high, script_code = unpack(range)&lt;br /&gt;
		printed_ranges:insert((&amp;#039;\t\t{ 0x%05X, 0x%05X, &amp;quot;%s&amp;quot; },&amp;#039;):format(low, high, script_code))&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local printed_singles = Array()&lt;br /&gt;
	for codepoint, script_code in require &amp;#039;Module:TableTools&amp;#039;.sortedPairs(singles) do&lt;br /&gt;
		printed_singles:insert((&amp;#039;\t\t[0x%05X] = &amp;quot;%s&amp;quot;,&amp;#039;):format(codepoint, script_code))&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local printed_script_name_to_code = Array()&lt;br /&gt;
	for name, code in require &amp;#039;Module:TableTools&amp;#039;.sortedPairs(script_name_to_code,&lt;br /&gt;
			function(name1, name2)&lt;br /&gt;
				return script_name_to_code[name1] &amp;lt; script_name_to_code[name2]&lt;br /&gt;
			end) do&lt;br /&gt;
		printed_script_name_to_code:insert((&amp;#039;\t\t%s = &amp;quot;%s&amp;quot;,&amp;#039;):format(code, name:gsub(&amp;#039;_&amp;#039;, &amp;#039; &amp;#039;)))&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local data = template&lt;br /&gt;
		:gsub(&amp;#039;%.%.%.&amp;#039;, printed_singles:concat(&amp;#039;\n&amp;#039;), 1)&lt;br /&gt;
		:gsub(&amp;#039;%.%.%.&amp;#039;, printed_ranges:concat(&amp;#039;\n&amp;#039;), 1)&lt;br /&gt;
		:gsub(&amp;#039;%.%.%.&amp;#039;, printed_script_name_to_code:concat(&amp;#039;\n&amp;#039;), 1)&lt;br /&gt;
	&lt;br /&gt;
	return data&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.highlight(lua_code)&lt;br /&gt;
	return mw.getCurrentFrame():extensionTag{&lt;br /&gt;
		name = &amp;quot;syntaxhighlight&amp;quot;,&lt;br /&gt;
		content = lua_code,&lt;br /&gt;
		args = { lang = &amp;quot;lua&amp;quot; }&lt;br /&gt;
	}&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
	local dir = &amp;#039;User:Erutuon/Unicode&amp;#039;&lt;br /&gt;
	local scripts_txt = dir .. &amp;#039;/Scripts.txt&amp;#039;&lt;br /&gt;
	local property_value_aliases_txt = dir ..&amp;#039;/PropertyValueAliases.txt&amp;#039;&lt;br /&gt;
	&lt;br /&gt;
	return p.highlight(p.make_script_data(scripts_txt, property_value_aliases_txt))&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>