Module:Unicode chart/sandbox: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
 
(19 intermediate revisions by the same user not shown)
Line 28:
}
 
local linebreakAbbrhardcodedNumberedAbbrSets = {
-- Block: Variation Selectors
{first = 0xFE00, last = 0xFE0F, str = "VS<br>", startNum = 1},
Line 95:
 
local function getCategory(codepoint)
-- local category = mCategory.long_names[
-- mUnicode.lookup_category(codepoint.int)
-- ]
local category = mUnicode.lookup_control(codepoint.int)
if category ~= "unassigned" then
Line 125 ⟶ 122:
---------------------
local function getCellAbbr(codepoint, category, args)
local function getHardcodedExceptionAbbrgetHardcodedNumberedAbbr(codepoint)
for key, value in pairs(linebreakAbbrhardcodedNumberedAbbrSets) do
if codepoint.int >= value.first
and codepoint.int <= value.last then
return value.str .. (codepoint.int - value.first + value.startNum)
end
end
Line 135 ⟶ 132:
end
function getAliasAbbr(codepoint)
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
Line 144 ⟶ 138:
-- end
--end
return alias
local function getAliasAbbr(codepoint)
local tbl = getAliasValues(codepoint.int, "abbreviation")
return aliastbl[1] or nil
end
local function abbrFromString(codepoint, args)
local abbr = ""
local name = mUnicode.lookup_name(codepoint.int)
Line 162 ⟶ 159:
end
--exception listed at top
local abbr1 = getHardcodedExceptionAbbrgetHardcodedNumberedAbbr(codepoint)
if abbr1 then return abbr1 end
--abbr on list
Line 182 ⟶ 179:
end
return aliasStr
end
 
local function linkChar(unicodeChar, codepoint, args)
if (args['link_sub'] and args['link_sub'][codepoint.int]) then
..return '&#x[[' .. args['suffixlink_sub'][codepoint.int] .. ';'
--unicodeChar = '[[' .. redir .. '|' .. unicodeChar .. ']]'
elseif args['link'] == "wiktwiki" then
local redir = mRedirect.luaMain(unicodeChar, false)
unicodeChar =-- '[[wikt:' .. unicodeCharredir .. '|' .. unicodeChar .. ']]'
unicodeChar =return expandTemplate('Link if exists', {unicodeChar})
elseif args['link'] == "wikt" then
return '[[wikt:' .. unicodeChar =.. '|' .. unicodeChar .. ']]'
end
end
 
Line 191 ⟶ 201:
end
local function abbrCell(abbr)
cell:addClass("abbr-boxcell")
cell:tag("div"):addClass("abbr-box"):wikitext(abbr)
end
Line 206 ⟶ 216:
else
local unicodeChar = '&#x'.. codepoint.hex .. ';'
unicodeChar = linkChar(unicodeChar, codepoint, args) or unicodeChar
if (args['link_sub'] and args['link_sub'][codepoint.int]) then
unicodeCharif = '[args['suffix'] ..and args['link_subsuffix'][codepoint.int] then
..unicodeChar '|' ..= unicodeChar .. ']]'
elseif .. '&#x' .. args['linksuffix'][codepoint.int] ==.. "wiki" then';'
cell:addClass("modified")
local redir = mRedirect.luaMain(unicodeChar, false)
--unicodeChar = '[[' .. redir .. '|' .. unicodeChar .. ']]'
unicodeChar = expandTemplate('Link if exists', {unicodeChar})
elseif args['link'] == "wikt" then
unicodeChar = '[[wikt:' .. unicodeChar .. '|' .. unicodeChar .. ']]'
end
if args['wrapper'] then
Line 220 ⟶ 226:
elseif args['font'] then
cell:css("font-family", "'" .. args['font'] .. "'")
--unicodeChar = tostring(
end
-- mw.html.create("div")
if args['suffix'] and args['suffix'][codepoint.int] then
-- :css("font-family", "'" .. args['font'] .. "'")
unicodeChar = unicodeChar
-- :wikitext(unicodeChar)
.. '&#x' .. args['suffix'][codepoint.int] .. ';'
--)
cell:addClass("modified")
end
cell:wikitext(unicodeChar)
Line 257 ⟶ 263:
local row = body:tag("tr")
row:tag("th"):wikitext("U+".. rowHex .. "<i>x</i>")
:attr("rowspan", "2")
for colIndex=0, 15 do
local cell = row:tag("td")
--rowHex .. string.format("%X", colIndex)
createCell(cell,
newCodepoint(rowHexrowIndex*16 .. string.format("%X",+ colIndex)),
args
)
end
local subrow = body:tag("tr")
for colIndex=0, 15 do
subrow:tag("td"):addClass("codepoint")
:wikitext(string.format("%04X", rowIndex*16 + colIndex))
end
end
Line 344 ⟶ 357:
end
end
-- look up block by na,e
if args['blockname'] then
local range = mUnicode.get_block_info(args['blockname'])
Line 354 ⟶ 369:
args
)
-- block given as start and end of range
elseif args['rangestart'] and args['rangeend'] then
return createTable(