summaryrefslogtreecommitdiff
path: root/tex/context/base/x-mathml.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/x-mathml.lua')
-rw-r--r--tex/context/base/x-mathml.lua465
1 files changed, 234 insertions, 231 deletions
diff --git a/tex/context/base/x-mathml.lua b/tex/context/base/x-mathml.lua
index 209f575e1..99ea6c34b 100644
--- a/tex/context/base/x-mathml.lua
+++ b/tex/context/base/x-mathml.lua
@@ -27,55 +27,55 @@ lxml.mml = lxml.mml or { }
local doublebar = utfchar(0x2016)
local n_replacements = {
--- [" "] = utfchar(0x2002), -- "&textspace;" -> tricky, no &; in mkiv
- ["."] = "{.}",
- [","] = "{,}",
- [" "] = "",
+-- [" "] = utfchar(0x2002), -- "&textspace;" -> tricky, no &; in mkiv
+ ["."] = "{.}",
+ [","] = "{,}",
+ [" "] = "",
}
local l_replacements = { -- in main table
- ["|"] = "\\mmlleftdelimiter\\vert",
- ["{"] = "\\mmlleftdelimiter\\lbrace",
- ["("] = "\\mmlleftdelimiter(",
- ["["] = "\\mmlleftdelimiter[",
- ["<"] = "\\mmlleftdelimiter<",
- [doublebar] = "\\mmlleftdelimiter\\Vert",
+ ["|"] = "\\mmlleftdelimiter\\vert",
+ ["{"] = "\\mmlleftdelimiter\\lbrace",
+ ["("] = "\\mmlleftdelimiter(",
+ ["["] = "\\mmlleftdelimiter[",
+ ["<"] = "\\mmlleftdelimiter<",
+ [doublebar] = "\\mmlleftdelimiter\\Vert",
}
local r_replacements = { -- in main table
- ["|"] = "\\mmlrightdelimiter\\vert",
- ["}"] = "\\mmlrightdelimiter\\rbrace",
- [")"] = "\\mmlrightdelimiter)",
- ["]"] = "\\mmlrightdelimiter]",
- [">"] = "\\mmlrightdelimiter>",
- [doublebar] = "\\mmlrightdelimiter\\Vert",
+ ["|"] = "\\mmlrightdelimiter\\vert",
+ ["}"] = "\\mmlrightdelimiter\\rbrace",
+ [")"] = "\\mmlrightdelimiter)",
+ ["]"] = "\\mmlrightdelimiter]",
+ [">"] = "\\mmlrightdelimiter>",
+ [doublebar] = "\\mmlrightdelimiter\\Vert",
}
local o_replacements = { -- in main table
- ["@l"] = "\\mmlleftdelimiter.",
- ["@r"] = "\\mmlrightdelimiter.",
- ["{"] = "\\mmlleftdelimiter\\lbrace",
- ["}"] = "\\mmlrightdelimiter\\rbrace",
- ["|"] = "\\mmlleftorrightdelimiter\\vert",
- [doublebar] = "\\mmlleftorrightdelimiter\\Vert",
- ["("] = "\\mmlleftdelimiter(",
- [")"] = "\\mmlrightdelimiter)",
- ["["] = "\\mmlleftdelimiter[",
- ["]"] = "\\mmlrightdelimiter]",
- ["<"] = "\\mmlleftdelimiter<",
- [">"] = "\\mmlrightdelimiter>",
- ["#"] = "\\mmlchar{35}",
- ["$"] = "\\mmlchar{36}", -- $
- ["%"] = "\\mmlchar{37}",
- ["&"] = "\\mmlchar{38}",
- ["^"] = "\\mmlchar{94}{}", -- strange, sometimes luatex math sees the char instead of \char
- ["_"] = "\\mmlchar{95}{}", -- so we need the {}
- ["~"] = "\\mmlchar{126}",
- [" "] = "",
- ["°"] = "^\\circ", -- hack
-
- [utfchar(0xF103C)] = "\\mmlleftdelimiter<",
+ ["@l"] = "\\mmlleftdelimiter.",
+ ["@r"] = "\\mmlrightdelimiter.",
+ ["{"] = "\\mmlleftdelimiter \\lbrace",
+ ["}"] = "\\mmlrightdelimiter\\rbrace",
+ ["|"] = "\\mmlleftorrightdelimiter\\vert",
+ [doublebar] = "\\mmlleftorrightdelimiter\\Vert",
+ ["("] = "\\mmlleftdelimiter(",
+ [")"] = "\\mmlrightdelimiter)",
+ ["["] = "\\mmlleftdelimiter[",
+ ["]"] = "\\mmlrightdelimiter]",
+ -- ["<"] = "\\mmlleftdelimiter<",
+ -- [">"] = "\\mmlrightdelimiter>",
+ ["#"] = "\\mmlchar{35}",
+ ["$"] = "\\mmlchar{36}", -- $
+ ["%"] = "\\mmlchar{37}",
+ ["&"] = "\\mmlchar{38}",
+ ["^"] = "\\mmlchar{94}{}", -- strange, sometimes luatex math sees the char instead of \char
+ ["_"] = "\\mmlchar{95}{}", -- so we need the {}
+ ["~"] = "\\mmlchar{126}",
+ [" "] = "",
+ ["°"] = "^\\circ", -- hack
+
+ -- [utfchar(0xF103C)] = "\\mmlleftdelimiter<",
[utfchar(0xF1026)] = "\\mmlchar{38}",
- [utfchar(0xF103E)] = "\\mmlleftdelimiter>",
+ -- [utfchar(0xF103E)] = "\\mmlleftdelimiter>",
}
@@ -137,250 +137,253 @@ local i_replacements = {
["as"] = "{\\mr as}",
}
+-- we could use a metatable or when accessing fallback on the
+-- key but at least we now have an overview
+
local csymbols = {
arith1 = {
- lcm = "lcm",
- big_lcm = "lcm",
- gcd = "gcd",
- big_gcd = "big_gcd",
- plus = "plus",
- unary_minus = "minus",
- minus = "minus",
- times = "times",
- divide = "divide",
- power = "power",
- abs = "abs",
- root = "root",
- sum = "sum",
- product ="product",
+ lcm = "lcm",
+ big_lcm = "lcm",
+ gcd = "gcd",
+ big_gcd = "big_gcd",
+ plus = "plus",
+ unary_minus = "minus",
+ minus = "minus",
+ times = "times",
+ divide = "divide",
+ power = "power",
+ abs = "abs",
+ root = "root",
+ sum = "sum",
+ product = "product",
},
fns = {
- domain = "domain",
- range = "codomain",
- image = "image",
- identity = "ident",
---~ left_inverse = "",
---~ right_inverse = "",
- inverse = "inverse",
- left_compose = "compose",
- lambda = "labmda",
+ domain = "domain",
+ range = "codomain",
+ image = "image",
+ identity = "ident",
+ -- left_inverse = "",
+ -- right_inverse = "",
+ inverse = "inverse",
+ left_compose = "compose",
+ lambda = "labmda",
},
linalg1 = {
- vectorproduct = "vectorproduct",
- scalarproduct = "scalarproduct",
- outerproduct = "outerproduct",
- transpose = "transpose",
- determinant = "determinant",
- vector_selector = "selector",
---~ matrix_selector = "matrix_selector",
+ vectorproduct = "vectorproduct",
+ scalarproduct = "scalarproduct",
+ outerproduct = "outerproduct",
+ transpose = "transpose",
+ determinant = "determinant",
+ vector_selector = "selector",
+ -- matrix_selector = "matrix_selector",
},
logic1 = {
- equivalent = "equivalent",
- ["not"] = "not",
- ["and"] = "and",
---~ big_and = "",
- ["xor"] = "xor",
---~ big_xor = "",
- ["or"] = "or",
---~ big-or= "",
- implies = "implies",
- ["true"] = "true",
- ["false"] = "false",
+ equivalent = "equivalent",
+ ["not"] = "not",
+ ["and"] = "and",
+ -- big_and = "",
+ ["xor"] = "xor",
+ -- big_xor = "",
+ ["or"] = "or",
+ -- big-or = "",
+ implies = "implies",
+ ["true"] = "true",
+ ["false"] = "false",
},
nums1 = {
---~ based_integer = "based_integer"
- rational = "rational",
- inifinity = "infinity",
- e = "expenonentiale",
- i ="imaginaryi",
- pi = "pi",
- gamma = "gamma",
- NaN, "NaN",
+ -- based_integer = "based_integer"
+ rational = "rational",
+ inifinity = "infinity",
+ e = "expenonentiale",
+ i = "imaginaryi",
+ pi = "pi",
+ gamma = "gamma",
+ NaN = "NaN",
},
relation1 = {
- eq = "eq",
- lt = "lt",
- gt = "gt",
- neq = "neq",
- leq = "leq",
- geq = "geq",
- approx = "approx",
+ eq = "eq",
+ lt = "lt",
+ gt = "gt",
+ neq = "neq",
+ leq = "leq",
+ geq = "geq",
+ approx = "approx",
},
set1 = {
- cartesian_product = "cartesianproduct",
- empty_set = "emptyset",
- map = "map",
- size = "card",
---~ suchthat = "suchthat",
- set = "set",
- intersect = "intersect",
---~ big_intersect = "",
- union = "union",
---~ big_union = "",
- setdiff = "setdiff",
- subset = "subset",
- ["in"] = "in",
- notin = "notin",
- prsubset = "prsubset",
- notsubset = "notsubset",
- notprsubset = "notprsubset",
+ cartesian_product = "cartesianproduct",
+ empty_set = "emptyset",
+ map = "map",
+ size = "card",
+ -- suchthat = "suchthat",
+ set = "set",
+ intersect = "intersect",
+ -- big_intersect = "",
+ union = "union",
+ -- big_union = "",
+ setdiff = "setdiff",
+ subset = "subset",
+ ["in"] = "in",
+ notin = "notin",
+ prsubset = "prsubset",
+ notsubset = "notsubset",
+ notprsubset = "notprsubset",
},
veccalc1 = {
- divergence = "divergence",
- grad = "grad",
- curl = "curl",
- Laplacian = "laplacian",
+ divergence = "divergence",
+ grad = "grad",
+ curl = "curl",
+ Laplacian = "laplacian",
},
calculus1 = {
- diff = "diff",
---~ nthdiff = "",
- partialdiff = "partialdiff",
- int = "int",
---~ defint = "defint",
+ diff = "diff",
+ -- nthdiff = "",
+ partialdiff = "partialdiff",
+ int = "int",
+ -- defint = "defint",
},
integer1 = {
- factorof = "factorof",
- factorial = "factorial",
- quotient = "quotient",
- remainder = "rem",
+ factorof = "factorof",
+ factorial = "factorial",
+ quotient = "quotient",
+ remainder = "rem",
},
linalg2 = {
- vector = "vector",
- matrix = "matrix",
- matrixrow = "matrixrow",
+ vector = "vector",
+ matrix = "matrix",
+ matrixrow = "matrixrow",
},
mathmkeys = {
---~ equiv = "",
---~ contentequiv = "",
---~ contentequiv_strict = "",
+ -- equiv = "",
+ -- contentequiv = "",
+ -- contentequiv_strict = "",
},
rounding1 = {
- ceiling = "ceiling",
- floor = "floor",
---~ trunc = "trunc",
---~ round = "round",
+ ceiling = "ceiling",
+ floor = "floor",
+ -- trunc = "trunc",
+ -- round = "round",
},
setname1 = {
- P = "primes",
- N = "naturalnumbers",
- Z = "integers",
- rationals = "rationals",
- R = "reals",
- complexes = "complexes",
+ P = "primes",
+ N = "naturalnumbers",
+ Z = "integers",
+ rationals = "rationals",
+ R = "reals",
+ complexes = "complexes",
},
complex1 = {
---~ complex_cartesian = "complex_cartesian", -- ci ?
- real = "real",
- imaginary = "imaginary",
---~ complex_polar = "complex_polar", -- ci ?
- argument = "arg",
- conjugate = "conjugate",
+ -- complex_cartesian = "complex_cartesian", -- ci ?
+ real = "real",
+ imaginary = "imaginary",
+ -- complex_polar = "complex_polar", -- ci ?
+ argument = "arg",
+ conjugate = "conjugate",
},
interval1 = { -- not an apply
---~ "integer_interval" = "integer_interval",
- interval = "interval",
- interval_oo = { tag = "interval", closure = "open" },
- interval_cc = { tag = "interval", closure = "closed" },
- interval_oc = { tag = "interval", closure = "open-closed" },
- interval_co = { tag = "interval", closure = "closed-open" },
+ -- integer_interval = "integer_interval",
+ interval = "interval",
+ interval_oo = { tag = "interval", closure = "open" },
+ interval_cc = { tag = "interval", closure = "closed" },
+ interval_oc = { tag = "interval", closure = "open-closed" },
+ interval_co = { tag = "interval", closure = "closed-open" },
},
linalg3 = {
---~ vector = "vector.column",
---~ matrixcolumn = "matrixcolumn",
---~ matrix = "matrix.column",
+ -- vector = "vector.column",
+ -- matrixcolumn = "matrixcolumn",
+ -- matrix = "matrix.column",
},
minmax1 = {
- min = "min",
---~ big_min = "",
- max = "max",
---~ big_max = "",
+ min = "min",
+ -- big_min = "",
+ max = "max",
+ -- big_max = "",
},
piece1 = {
- piecewise = "piecewise",
- piece = "piece",
- otherwise = "otherwise",
+ piecewise = "piecewise",
+ piece = "piece",
+ otherwise = "otherwise",
},
error1 = {
---~ unhandled_symbol = "",
---~ unexpected_symbol = "",
---~ unsupported_CD = "",
+ -- unhandled_symbol = "",
+ -- unexpected_symbol = "",
+ -- unsupported_CD = "",
},
limit1 = {
---~ limit = "limit",
---~ both_sides = "both_sides",
---~ above = "above",
---~ below = "below",
---~ null = "null",
- tendsto = "tendsto",
+ -- limit = "limit",
+ -- both_sides = "both_sides",
+ -- above = "above",
+ -- below = "below",
+ -- null = "null",
+ tendsto = "tendsto",
},
list1 = {
---~ map = "",
---~ suchthat = "",
---~ list = "list",
+ -- map = "",
+ -- suchthat = "",
+ -- list = "list",
},
multiset1 = {
- size = { tag = "card", type="multiset" },
- cartesian_product = { tag = "cartesianproduct", type="multiset" },
- empty_set = { tag = "emptyset", type="multiset" },
---~ multi_set = { tag = "multiset", type="multiset" },
- intersect = { tag = "intersect", type="multiset" },
---~ big_intersect = "",
- union = { tag = "union", type="multiset" },
---~ big_union = "",
- setdiff = { tag = "setdiff", type="multiset" },
- subset = { tag = "subset", type="multiset" },
- ["in"] = { tag = "in", type="multiset" },
- notin = { tag = "notin", type="multiset" },
- prsubset = { tag = "prsubset", type="multiset" },
- notsubset = { tag = "notsubset", type="multiset" },
- notprsubset = { tag = "notprsubset", type="multiset" },
+ size = { tag = "card", type = "multiset" },
+ cartesian_product = { tag = "cartesianproduct", type = "multiset" },
+ empty_set = { tag = "emptyset", type = "multiset" },
+ -- multi_set = { tag = "multiset", type = "multiset" },
+ intersect = { tag = "intersect", type = "multiset" },
+ -- big_intersect = "",
+ union = { tag = "union", type = "multiset" },
+ -- big_union = "",
+ setdiff = { tag = "setdiff", type = "multiset" },
+ subset = { tag = "subset", type = "multiset" },
+ ["in"] = { tag = "in", type = "multiset" },
+ notin = { tag = "notin", type = "multiset" },
+ prsubset = { tag = "prsubset", type = "multiset" },
+ notsubset = { tag = "notsubset", type = "multiset" },
+ notprsubset = { tag = "notprsubset", type = "multiset" },
},
quant1 = {
- forall = "forall",
- exists = "exists",
+ forall = "forall",
+ exists = "exists",
},
s_dist = {
---~ mean = "mean.dist",
---~ sdev = "sdev.dist",
---~ variance = "variance.dist",
---~ moment = "moment.dist",
+ -- mean = "mean.dist",
+ -- sdev = "sdev.dist",
+ -- variance = "variance.dist",
+ -- moment = "moment.dist",
},
s_data = {
- mean = "mean",
- sdev = "sdev",
- variance = "vriance",
- mode = "mode",
- median = "median",
- moment = "moment",
+ mean = "mean",
+ sdev = "sdev",
+ variance = "vriance",
+ mode = "mode",
+ median = "median",
+ moment = "moment",
},
transc1 = {
- log = "log",
- ln = "ln",
- exp = "exp",
- sin = "sin",
- cos = "cos",
- tan = "tan",
- sec = "sec",
- csc = "csc",
- cot = "cot",
- sinh = "sinh",
- cosh = "cosh",
- tanh = "tanh",
- sech = "sech",
- csch = "cscs",
- coth = "coth",
- arcsin = "arcsin",
- arccos = "arccos",
- arctan = "arctan",
- arcsec = "arcsec",
- arcscs = "arccsc",
- arccot = "arccot",
- arcsinh = "arcsinh",
- arccosh = "arccosh",
- arctanh = "arstanh",
- arcsech = "arcsech",
- arccsch = "arccsch",
- arccoth = "arccoth",
+ log = "log",
+ ln = "ln",
+ exp = "exp",
+ sin = "sin",
+ cos = "cos",
+ tan = "tan",
+ sec = "sec",
+ csc = "csc",
+ cot = "cot",
+ sinh = "sinh",
+ cosh = "cosh",
+ tanh = "tanh",
+ sech = "sech",
+ csch = "cscs",
+ coth = "coth",
+ arcsin = "arcsin",
+ arccos = "arccos",
+ arctan = "arctan",
+ arcsec = "arcsec",
+ arcscs = "arccsc",
+ arccot = "arccot",
+ arcsinh = "arcsinh",
+ arccosh = "arccosh",
+ arctanh = "arstanh",
+ arcsech = "arcsech",
+ arccsch = "arccsch",
+ arccoth = "arccoth",
},
}
@@ -450,7 +453,7 @@ function lxml.mml.stripped(str)
tex.sprint(ctxcatcodes,str:strip())
end
-function characters.remapentity(chr,slot)
+function characters.remapentity(chr,slot) -- brrrrrr
texsprint(format("{\\catcode%s=13\\xdef%s{\\string%s}}",slot,utfchar(slot),chr))
end