Module:Unicode chart/sandbox: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Line 26:
flag = false
}
}
 
local linebreakAbbr = {
-- Block: Variation Selectors
{first = 0xFE00, last = 0xFE0F, str = "VS<br>", startNum = 1},
-- Block: Variation Selectors Supplement
{first = 0xE0100, last = 0xE01EF, str = "VS<br>", startNum = 17},
-- Block: Sutton SignWriting
-- SIGNWRITING FILL MODIFIER-2 -> SW F#
{first = 0x1DA9B, last = 0x1DA9F, str = 'SW<br>F', startNum = 2},
-- Block: Sutton SignWriting
-- SIGNWRITING ROTATION MODIFIER-2 -> SW R#
{first = 0x1DAA1, last = 0x1DAAF, str = 'SW<br>R', startNum = 2},
}
 
Line 34 ⟶ 47:
func = function(codepoint, abbr)
return '&#x'.. string.format("%04X", (codepoint - 0xE0000)) .. ';'
end
},
-- Unicode block: Variation Selectors
-- adding line breaks
{first = 0xFE00, last = 0xFE0F,
func = function(codepoint, abbr)
return abbr:gsub("VS", "VS<br>")
end
},
{first = 0xE0100, last = 0xE01EF,-- Variation Selectors Supplement
func = function(codepoint, abbr)
return abbr:gsub("VS", "VS<br>")
end
},
-- Unicode block: Sutton SignWriting
-- SIGNWRITING FILL MODIFIER-2 -> SW F#
{first = 0x1DA9B, last = 0x1DA9F,
func = function(codepoint, abbr)
return 'SW<br>F'.. (codepoint - 0x1DA99)
end
},
-- SIGNWRITING ROTATION MODIFIER-2 -> SW R#
{first = 0x1DAA1, last = 0x1DAAF,
func = function(codepoint, abbr)
return 'SW<br>R'.. (codepoint - 0x1DA9F)
end
},
Line 133 ⟶ 121:
end
 
---------------------
local function lastAbbr(codepoint)
-- A single unicode cell within the table
local tbl = getAliasValues(codepoint.int, "abbreviation")
---------------------
local alias = tbl[#tbl] or nil -- last one
local function getCellAbbr(codepoint, args)
for key, value in pairs(specialFormatSets) do
function getHardcodedExceptionAbbr(codepoint)
if codepoint.int >= value.first
for key, value in pairs(linebreakAbbr) do
and codepoint.int <= value.last then
returnif value.func(codepoint.int, alias)>= value.first
and codepoint.int <= value.last then
return value.str .. (codepoint.int - value.first + startNum)
end
end
end
return alias
function getAliasAbbr(codepoint)
end
local tbl = getAliasValues(codepoint.int, "abbreviation")
local alias = tbl[#tbl] or nil -- last one
--for key, value in pairs(specialFormatSets) do
-- if codepoint.int >= value.first
-- and codepoint.int <= value.last then
-- return value.func(codepoint.int, alias)
-- end
--end
return alias
end
function abbrFromString(codepoint)
local abbr = ""
local name = mUnicode.lookup_name(codepoint.int)
local words = mw.text.split(name, ' ')
for _,w in pairs(words) do
abbr = abbr .. string.sub(w, 1, 1)
end
return abbr
end
 
--override
local function abbrFromString(str)
if (args['abbr_sub'] and args['abbr_sub'][codepoint.int]) then
local words = mw.text.split(str, ' ')
return args['abbr_sub'][codepoint.int]
local abbr = ""
for _,w in pairs(words) do
abbr = abbr .. string.sub(w, 1, 1)
end
--exception listed at top
return abbr
local abbr = getHardcodedExceptionAbbr(codepoint)
if abbr then return abbr end
--abbr on list
local abbr = getAliasAbbr(codepoint)
if abbr then return abbr end
--make own abbr
if category == "control" or category == "format" then
return '<span class="red">' .. abbrFromString(codepoint) .. '</span>'
end
return false
end
 
---------------------
-- A single unicode cell within the table
---------------------
local function aliasesStr(codepoint)
local aliasStr = ""
Line 179 ⟶ 195:
-- main func begins
local nameabbr = mUnicode.lookup_namegetCellAbbr(codepoint.int)
local abbr = lastAbbr(codepoint)
local category = getCategory(codepoint)
cell:addClass(category)
Line 186 ⟶ 201:
if category == "reserved" or category == "noncharacter" then
emptyCell(category)
elseif (args['abbr_sub'] and args['abbr_sub'][codepoint.int]) then
abbrCell(args['abbr_sub'][codepoint.int])
elseif abbr then
abbrCell(abbr)
elseif category == "control" or category == "format" then
abbrCell('<span class="red">' .. abbrFromString(name) .. '</span>')
else
local unicodeChar = '&#x'.. codepoint.hex .. ';'
Line 216 ⟶ 227:
cell:wikitext(unicodeChar)
end
local name = mUnicode.lookup_name(codepoint.int)
name = string.match(name, "<([a-z]+)-%w+>") or name
cell:attr("title",