मॉड्यूल:calligraphy
"इस मॉड्यूल हेतु प्रलेख मॉड्यूल:calligraphy/doc पर बनाया जा सकता है"
local export = {}
local code_points = {
pattern = {
Latn_capital = "[A-Z]",
Latn_small = "[a-z]",
Grek_capital = "[Α-Ω]",
Grek_small = "[α-ω]",
digit = "[0-9]"
},
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
["i"] = {
[""]="ℎ"
},
["s"] = {
[""]="ℬ", [""]="ℰ", [""]="ℱ", [""]="ℋ", [""]="ℐ", [""]="ℒ", [""]="ℳ", [""]="ℛ", [""]="ℯ", [""]="ℊ", [""]="ℴ"
},
["f"] = {
[""]="ℭ", [""]="ℌ", [""]="ℑ", [""]="ℜ", [""]="ℨ"
},
["ds"] = {
[""]="ℂ", [""]="ℍ", [""]="ℕ", [""]="ℙ", [""]="ℚ", [""]="ℝ", [""]="ℤ"
}
};
function export.show(frame)
local mode = frame:getParent().args[1]
local text = frame:getParent().args[2]
text = mw.ustring.gsub(text, code_points.pattern.Latn_capital, function(a)
return mw.ustring.char(mw.ustring.codepoint(a) - code_points.normal.Latn + code_points[mode].Latn)
end)
text = mw.ustring.gsub(text, code_points.pattern.Latn_small, function(a)
return mw.ustring.char(mw.ustring.codepoint(a) - code_points.normal.Latn + code_points[mode].Latn - 6)
end)
text = mw.ustring.gsub(text, code_points.pattern.Grek_capital, function(a)
return mw.ustring.char(mw.ustring.codepoint(a) - code_points.normal.Grek + code_points[mode].Grek)
end)
text = mw.ustring.gsub(text, code_points.pattern.Grek_small, function(a)
return mw.ustring.char(mw.ustring.codepoint(a) - code_points.normal.Grek + code_points[mode].Grek - 6)
end)
text = mw.ustring.gsub(text, code_points.pattern.digit, function(a)
return mw.ustring.char(mw.ustring.codepoint(a) - code_points.normal.digit + code_points[mode].digit)
end)
if mode == "i" or mode == "s" or mode == "f" or mode == "ds" then
text = mw.ustring.gsub(text, ".", fixes[mode])
end
return text
end
return export