Script error: The function "main" does not exist.

local export = {}

local function getBlock(char)
	if type(char) ~= "number" then
		char = mw.ustring.codepoint(char)
	end
	
	-- Don't return a block not currently serviced by [[Module:zh-sortkey]] (or an unassigned one).
	if char >= 13312 and char <= 40938 or char >= 131072 and char <= 191456 then
		return require("Модул:Unicode data").lookup_block(char)
	else
		return nil
	end
end

local function getBlocks(moduleNumber, start, moduleStart)
	local firstChar = ( moduleNumber - moduleStart ) * 500 + start
	local lastChar = firstChar + 500 - 1
	
	local blocks = {}
	table.insert( blocks, getBlock(firstChar) )
	table.insert( blocks, getBlock(lastChar) )
	
--	mw.log(firstChar, lastChar, blocks[1], blocks[2])
	
	return blocks
end

function export.getDescription(frame)
	local title = mw.title.getCurrentTitle()
	local namespace = title.nsText
	local pagename = title.text
	local subpage = title.subpageText
	
	local moduleNumber = pagename:match("^zh%-sortkey/data/(%d+)")
	if moduleNumber then
		moduleNumber = tonumber(moduleNumber)
	else
		require("Модул:debug").track("zh-sortkey/failed")
		return nil
	end
	
	local blocks
	
	if moduleNumber <= 56 then
		blocks = getBlocks(moduleNumber, 13312, 1)
	elseif moduleNumber <= 177 then
		blocks = getBlocks(moduleNumber, 131072, 57)
	else
		require("Модул:debug").track("zh-sortkey/failed")
		return nil
	end
	
	local function link(text)
		return "[[w:" .. text .. "|" .. text .. "]] block ([[:Категорија:" .. text .. " block|category]])[[Категорија:" .. text .. " block| ]]"
	end
	
	local out = {}
	-- Link any unique blocks that were found.
	for i = 1, 2 do
		if blocks[i] then
			-- Don't insert the same block twice.
			if not blocks[blocks[i]] then
				table.insert( out, link(blocks[i]) )
			end
			blocks[blocks[i]] = true
		end
	end
	if #out > 0 then
		out = table.concat(out, " и ")
	else
		require("Модул:debug").track("zh-sortkey/failed")
		return nil
	end
	
	return " These are sortkeys for Chinese characters from " .. out .. ", indexed by Unicode codepoint (in decimal base)."
end

return export