Module:User:Erutuon/titles by script

Hello, you have come here looking for the meaning of the word Module:User:Erutuon/titles by script. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:User:Erutuon/titles by script, but we will also tell you about its etymology, its characteristics and you will know how to say Module:User:Erutuon/titles by script in singular and plural. Everything you need to know about the word Module:User:Erutuon/titles by script you have here. The definition of the word Module:User:Erutuon/titles by script will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:User:Erutuon/titles by script, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.


local export = {}

local Array = require "Module:array"

local floor = math.floor
local function binary_range_search(codepoint, ranges)
	local low, mid, high
	low, high = 1, #ranges
	while low <= high do
		mid = floor((low + high) / 2)
		local range = ranges
		if codepoint < range then
			high = mid - 1
		elseif codepoint <= range then
			return range, mid
		else
			low = mid + 1
		end
	end
	return nil, mid
end

local script_data = require "Module:User:Erutuon/titles by script/data"
local function lookup_script(codepoint)
	if script_data.singles then
		return script_data.singles
	else
		local range = binary_range_search(codepoint, script_data.ranges)
		if range then
			return range
		else
			return "Zzzz"
		end
	end
end

local function excluded_title(title_object)
	local title = title_object.fullText
	return not (title:find "кварк"
		or title:find "витамин" or title:find "^Unsupported titles/")
		and title_object.exists and not title_object.isRedirect
end

local function make_table(caption)
	local titles = mw.title.new(mw.title.getCurrentTitle().fullText .. "/data")
		:getContent():match("%s*<pre><nowiki>%s*(.-)%s*</nowiki></pre>%s*")
	
	local output = Array()
	
	output:insert [[
{| class="wikitable sortable"
]]
	if caption then
		output:insert("|+ " .. caption .. "\n")
	end
	
	output:insert [[
! title !! characters
]]
	
	local lookup_name = require "Module:Unicode data".lookup_name
	
	for title in mw.text.gsplit(titles, "\n") do
		local characters_by_script = { Latn = Array(), Cyrl = Array(), Grek = Array() }
		for codepoint in mw.ustring.gcodepoint(title) do
			local script = lookup_script(codepoint)
			if characters_by_script then
				local name = lookup_name(codepoint)
				characters_by_script:insert { name = name, char = mw.ustring.char(codepoint) }
			end
		end
		title = "]"
		output:insert("|-\n| " .. title .. "\n")
		output:insert("| ")
		local script_list = Array()
		for script, characters in require "Module:table".sortedPairs(characters_by_script) do
			if #characters > 0 then
				local character_list = characters
					:map(
						function (character)
							return '<span class="' .. script
								.. '" title="' .. character.name .. '">'
								.. character.char .. '</span>'
						end)
					:concat()
				script_list:insert(script .. ": " .. character_list)
			end
		end
		output:insert(script_list:concat "; ")
		output:insert "\n"
	end
	
	output:insert "|}"
	
	return output:concat()
end

function export.show_Cyrillic_and_Latin(frame)
	return make_table [[
Mainspace titles with Cyrillic and Latin<br>(except redirects and titles with <span class="Cyrl">кварк</span>)]]
end

function export.show_Greek_and_Latin(frame)
	return make_table()
end

return export