This module implements {{calligraphy}}
.
local m_str_utils = require("Module:string utilities")
local codepoint = m_str_utils.codepoint
local u = m_str_utils.char
local ugsub = m_str_utils.gsub
local export = {}
local code_points = {
pattern = {
Latn_capital = "",
Latn_small = "",
Grek_capital = "",
Grek_small = "",
digit = ""
},
normal = {
Latn = 65,
Grek = 913,
digit = 48
},
b = {
Latn = 119808,
Grek = 120488,
digit = 120782
},
i = {
Latn = 119860,
Grek = 120546,
digit = 48
},
bi = {
Latn = 119912,
Grek = 120604,
digit = 48
},
s = {
Latn = 119964,
Grek = 913,
digit = 48
},
bs = {
Latn = 120016,
Grek = 913,
digit = 48
},
f = {
Latn = 120068,
Grek = 913,
digit = 48
},
ds = {
Latn = 120120,
Grek = 913,
digit = 120792
},
bf = {
Latn = 120172,
Grek = 913,
digit = 48
},
ss = {
Latn = 120224,
Grek = 913,
digit = 120802
},
ssb = {
Latn = 120276,
Grek = 120662,
digit = 120812
},
ssi = {
Latn = 120328,
Grek = 913,
digit = 48
},
ssbi = {
Latn = 120380,
Grek = 120720,
digit = 48
},
m = {
Latn = 120432,
Grek = 913,
digit = 120822
},
}
local fixes = { -- some characters are in the BMP, separated from their peers
= {
="ℎ"
},
= {
="ℬ", ="ℰ", ="ℱ", ="ℋ", ="ℐ", ="ℒ", ="ℳ", ="ℛ", ="ℯ", ="ℊ", ="ℴ"
},
= {
="ℭ", ="ℌ", ="ℑ", ="ℜ", ="ℨ"
},
= {
="ℂ", ="ℍ", ="ℕ", ="ℙ", ="ℚ", ="ℝ", ="ℤ"
}
};
function export.show(frame)
local mode = frame:getParent().args
local text = frame:getParent().args
text = ugsub(text, code_points.pattern.Latn_capital, function(a)
return u(codepoint(a) - code_points.normal.Latn + code_points.Latn)
end)
text = ugsub(text, code_points.pattern.Latn_small, function(a)
return u(codepoint(a) - code_points.normal.Latn + code_points.Latn - 6)
end)
text = ugsub(text, code_points.pattern.Grek_capital, function(a)
return u(codepoint(a) - code_points.normal.Grek + code_points.Grek)
end)
text = ugsub(text, code_points.pattern.Grek_small, function(a)
return u(codepoint(a) - code_points.normal.Grek + code_points.Grek - 6)
end)
text = ugsub(text, code_points.pattern.digit, function(a)
return u(codepoint(a) - code_points.normal.digit + code_points.digit)
end)
if mode == "i" or mode == "s" or mode == "f" or mode == "ds" then
text = ugsub(text, ".", fixes)
end
return text
end
return export