Normalize some names of combining characters

The list remaps according to the table in MathML-Core, always selecting
the variant which has an XML entity name is such a character exists.
This commit is contained in:
Marcel Krüger 2021-04-19 17:07:29 +02:00
parent 057aec4e6f
commit 2a96d1c7d6
2 changed files with 31 additions and 0 deletions

View File

@ -1,3 +1,5 @@
local remap_comb = require'remap_comb'
local noad_t, accent_t, style_t, choice_t = node.id'noad', node.id'accent', node.id'style', node.id'choice' local noad_t, accent_t, style_t, choice_t = node.id'noad', node.id'accent', node.id'style', node.id'choice'
local radical_t, fraction_t, fence_t = node.id'radical', node.id'fraction', node.id'fence' local radical_t, fraction_t, fence_t = node.id'radical', node.id'fraction', node.id'fence'
@ -102,12 +104,14 @@ local function accent_to_table(accent, sub, cur_style)
if sub & 1 == 1 then if sub & 1 == 1 then
top_acc.stretchy = 'false' top_acc.stretchy = 'false'
end end
top_acc[1] = remap_comb[top_acc[1]] or top_acc[1]
end end
if bot_acc then if bot_acc then
bot_acc[0] = 'mo' bot_acc[0] = 'mo'
if sub & 2 == 2 then if sub & 2 == 2 then
bot_acc.stretchy = 'false' bot_acc.stretchy = 'false'
end end
bot_acc[1] = remap_comb[bot_acc[1]] or bot_acc[1]
end end
return {[0] = top_acc and (bot_acc and 'munderover' or 'mover') or 'munder', return {[0] = top_acc and (bot_acc and 'munderover' or 'mover') or 'munder',
nucleus, nucleus,

27
remap_comb.lua Normal file
View File

@ -0,0 +1,27 @@
return {
["\u{0332}"] = "\u{2212}",
["\u{0330}"] = "\u{02DC}",
["\u{0328}"] = "\u{02DB}",
["\u{20EF}"] = "\u{2192}",
["\u{032C}"] = "\u{02C7}",
["\u{032E}"] = "\u{02D8}",
["\u{0306}"] = "\u{02D8}",
["\u{030B}"] = "\u{02DD}",
["\u{0302}"] = "\u{02C6}",
["\u{0324}"] = "\u{00A8}",
["\u{0317}"] = "\u{00B4}",
["\u{031F}"] = "\u{002B}",
["\u{0307}"] = "\u{002E}",
["\u{0305}"] = "\u{2212}",
["\u{0303}"] = "\u{02DC}",
["\u{0316}"] = "\u{0060}",
["\u{0301}"] = "\u{00B4}",
["\u{030C}"] = "\u{02C7}",
["\u{0327}"] = "\u{00B8}",
["\u{0308}"] = "\u{00A8}",
["\u{0300}"] = "\u{0060}",
["\u{0323}"] = "\u{002E}",
["\u{0304}"] = "\u{00AF}",
["\u{032D}"] = "\u{005E}",
["\u{20D7}"] = "\u{2192}",
}