Class: Plurimath::Mathml::Constants

Inherits:
Object
  • Object
show all
Defined in:
lib/plurimath/mathml/constants.rb

Constant Summary collapse

UNICODE_SYMBOLS =
{
  "α": "alpha",
  "β": "beta",
  "γ": "gamma",
  "Γ": "Gamma",
  "δ": "delta",
  "Δ": "Delta",
  "∆": "increment",
  "ε": "epsilon",
  "ɛ": "varepsilon",
  "ζ": "zeta",
  "η": "eta",
  "θ": "theta",
  "Θ": "Theta",
  "ϑ": "vartheta",
  "ι": "iota",
  "κ": "kappa",
  "λ": "lambda",
  "Λ": "Lambda",
  "μ": "mu",
  "ν": "nu",
  "ξ": "xi",
  "Ξ": "Xi",
  "π": "pi",
  "Π": "Pi",
  "ρ": "rho",
  "ς": "beta",
  "σ": "sigma",
  "Σ": "Sigma",
  "τ": "tau",
  "υ": "upsilon",
  "φ": "phi",
  "Φ": "Phi",
  "ϕ": "varphi",
  "χ": "chi",
  "ψ": "psi",
  "Ψ": "Psi",
  "ω": "omega",
  "Ω": "omega",
  "⋅": "cdot",
  "∙": "*",
  ".": ".",
  "∗": "**",
  "⋆": "***",
  "×": "xx",
  "&#x22c9;": "|><",
  "&#x22ca;": "><|",
  "&#x22c8;": "|><|",
  "&#xf7;": "-:",
  "&#x2218;": "@",
  "&#x2295;": "o+",
  "&#x2a01;": "o+",
  "&#x2297;": "ox",
  "&#x2299;": " ",
  "&#x2211;": "sum",
  "&#x220f;": "prod",
  "&#x2227;": "^^",
  "&#x22c0;": "^^^",
  "&#x2228;": "vv",
  "&#x22c1;": "vvv",
  "&#x2229;": "nn",
  "&#x22c2;": "nnn",
  "&#x222a;": "cup",
  "&#x22c3;": "uuu",
  "&#x2260;": "!=",
  "&#x2264;": "<=",
  "&#x2265;": ">=",
  "&#x227a;": "-<",
  "&#x227b;": ">-",
  "&#x2aaf;": "-<=",
  "&#x2ab0;": " >-=",
  "&#x2208;": "in",
  "&#x2209;": "!in",
  "&#x2282;": "sub",
  "&#x2283;": "sup",
  "&#x2286;": "sube",
  "&#x2287;": "supe",
  "&#x2261;": "-=",
  "&#x2245;": "~=",
  "&#x2248;": "~~",
  "&#x221d;": "prop",
  "&#xac;": "not",
  "&#x2200;": "AA",
  "&#x2203;": "EE",
  "&#x22a5;": "_|_",
  "&#x22a4;": "TT",
  "&#x22a2;": "|--",
  "&#x22a8;": "|==",
  "&#x2329;": "<<",
  "&#x232a;": ">>",
  "&#x222b;": "int",
  "&#x222e;": "oint",
  "&#x2202;": "del",
  "&#x2207;": "grad",
  "&#xb1;": "+-",
  "&#x2205;": "O/",
  "&#x221e;": "oo",
  "&#x2135;": "aleph",
  "&#x2234;": ":.",
  "&#x2235;": ":'",
  "&#x2220;": "/_",
  "&#x25b3;": "/_\\",
  "&#x2032;": "'",
  "&#xa0;&#xa0;": "quad",
  "&#xa0;&#xa0;&#xa0;&#xa0;": "qquad",
  "&#x203e;": "overline",
  "&#x2322;": "frown",
  "&#x22ef;": "cdots",
  "&#x22ee;": "vdots",
  "&#x22f1;": "ddots",
  "&#x22c4;": "diamond",
  "&#x25a1;": "square",
  "&#x230a;": "|__",
  "&#x230b;": "__|",
  "&#x2308;": "|~",
  "&#x2309;": "~|",
  "&#x2102;": "CC",
  "&#x2115;": "NN",
  "&#x211a;": "QQ",
  "&#x211d;": "RR",
  "&#x2124;": "ZZ",
  "&#x2191;": "uarr",
  "&#x2193;": "darr",
  "&#x2190;": "larr",
  "&#x2194;": "harr",
  "&#x21d2;": "rArr",
  "&#x21d0;": "lArr",
  "&#x21d4;": "hArr",
  "&#x21a3;": ">->",
  "&#x21a0;": "->>",
  "&#x2916;": ">->>",
  "&#x21a6;": "|->",
  "&#x2026;": "...",
  "&#x2212;": "-",
  "&#x23de;": "obrace",
  "&#x23df;": "ubrace",
  "&#x2192;": "vec",
  "&#x302;": "hat",
  "&#x305;": "bar",
  "&#x20e1;": "overleftrightarrow",
  "&#x332;": "ul",
  "&#xaf;": "bar",
  "&#x26;": "&",
  "&#x3e;": ">",
  "&#x3c;": "<",
  "&amp;": "&",
  "~": "tilde",
  "..": "ddot",
  "^": "hat",
  "¯": "bar",
  _: "ul",
}.freeze
SYMBOLS =
{
  "|": "|",
  "/": "//",
  "\\": "\\\\",
  "~": "tilde",
  "(": "(",
  ")": ")",
  "(:": "(:",
  ":)": ":)",
  "{": "{",
  "}": "}",
  "{:": "{:",
  ":}": ":}",
  "]": "]",
  "[": "[",
  "=": "=",
  "+": "+",
  "-": "-",
}.freeze
ACCENT_WORDS =

Over/under accent decorations. In MathML these are only ever expressed as <mover>/<munder> with a base (recovered from their diacritic CHARACTER), never as a bare <mi>/<mo> identifier word. So a bare token whose text is one of these names is a literal identifier (e.g. the unit “bar”), not the accent. See unitsml/unitsdb#123.

%w[
  bar overline ul hat vec tilde dot ddot obrace ubrace overleftrightarrow
].freeze
CLASSES =
%w[
  mathfrak
  underset
  stackrel
  overline
  overset
  overleftrightarrow
  mathcal
  arccos
  arcsin
  arctan
  mathsf
  mathbb
  mathbf
  mathtt
  ubrace
  obrace
  cancel
  tilde
  floor
  color
  frac
  root
  oint
  ceil
  ddot
  coth
  csch
  sech
  sinh
  tanh
  cosh
  sqrt
  norm
  text
  prod
  sec
  int
  sin
  tan
  cos
  sum
  exp
  gcd
  glb
  lcm
  lub
  cot
  csc
  det
  dim
  max
  min
  abs
  bar
  dot
  hat
  vec
  mod
  log
  ul
  ln
].freeze
OPERATORS =
[
  "&#x00a0;&#x00a0;&#x00a0;&#x00a0;",
  "&#x00a0;&#x00a0;",
  "&#x002a;",
  "&#x003c;",
  "&#x003e;",
  "&#x00a0;",
  "&#x00ac;",
  "&#x00b1;",
  "&#x00d7;",
  "&#x00f7;",
  "&#x0393;",
  "&#x0394;",
  "&#x0398;",
  "&#x039b;",
  "&#x039e;",
  "&#x03a0;",
  "&#x03a3;",
  "&#x03a9;",
  "&#x2026;",
  "&#x2032;",
  "&#x2102;",
  "&#x2115;",
  "&#x211a;",
  "&#x211d;",
  "&#x2124;",
  "&#x2135;",
  "&#x2190;",
  "&#x2191;",
  "&#x2192;",
  "&#x2192;",
  "&#x2193;",
  "&#x2194;",
  "&#x21a0;",
  "&#x21a3;",
  "&#x21a6;",
  "&#x21d0;",
  "&#x21d2;",
  "&#x21d2;",
  "&#x21d4;",
  "&#x21d4;",
  "&#x2200;",
  "&#x2202;",
  "&#x2203;",
  "&#x2205;",
  "&#x2207;",
  "&#x2208;",
  "&#x2209;",
  "&#x220f;",
  "&#x2211;",
  "&#x2212;",
  "&#x2213;",
  "&#x221d;",
  "&#x221e;",
  "&#x2220;",
  "&#x2227;",
  "&#x2228;",
  "&#x2229;",
  "&#x222a;",
  "&#x222b;",
  "&#x222e;",
  "&#x2234;",
  "&#x2235;",
  "&#x223c;",
  "&#x2245;",
  "&#x2248;",
  "&#x2254;",
  "&#x2260;",
  "&#x2261;",
  "&#x2264;",
  "&#x2265;",
  "&#x226a;",
  "&#x226b;",
  "&#x227a;",
  "&#x227b;",
  "&#x2282;",
  "&#x2283;",
  "&#x2286;",
  "&#x2287;",
  "&#x2295;",
  "&#x2297;",
  "&#x2299;",
  "&#x22a2;",
  "&#x22a4;",
  "&#x22a5;",
  "&#x22a8;",
  "&#x22c0;",
  "&#x22c1;",
  "&#x22c2;",
  "&#x22c3;",
  "&#x22c4;",
  "&#x22c5;",
  "&#x22c6;",
  "&#x22c8;",
  "&#x22c9;",
  "&#x22ca;",
  "&#x22ee;",
  "&#x22ef;",
  "&#x22f1;",
  "&#x2308;",
  "&#x2309;",
  "&#x230a;",
  "&#x230b;",
  "&#x2322;",
  "&#x25a1;",
  "&#x25b3;",
  "&#x26ac;",
  "&#x2916;",
  "&#x2aaf;",
  "&#x2ab0;",
  "&#x2b;",
  "&#x3d;",
  "&#x3a;",
  "&#x3c;",
  "&#xd7;",
  "&#xb1;",
  "&#x26;",
  "&#x3b;",
  "&#x3e;",
  "&#x7c;",
  "lim",
  "max",
  "min",
  "\\",
  "//",
  "/",
  "if",
  "^",
  "_",
  "+",
  "/",
  "=",
  ":",
  ",",
  ")",
  "(",
  "[",
  "]",
].freeze
SUPPORTED_FONT_STYLES =
{
  "sans-serif-bold-italic": Math::Function::FontStyle::SansSerifBoldItalic,
  "sans-serif-italic": Math::Function::FontStyle::SansSerifItalic,
  "bold-sans-serif": Math::Function::FontStyle::BoldSansSerif,
  "double-struck": Math::Function::FontStyle::DoubleStruck,
  "bold-fraktur": Math::Function::FontStyle::BoldFraktur,
  "bold-italic": Math::Function::FontStyle::BoldItalic,
  "bold-script": Math::Function::FontStyle::BoldScript,
  "sans-serif": Math::Function::FontStyle::SansSerif,
  monospace: Math::Function::FontStyle::Monospace,
  fraktur: Math::Function::FontStyle::Fraktur,
  normal: Math::Function::FontStyle::Normal,
  script: Math::Function::FontStyle::Script,
  italic: Math::Function::FontStyle::Italic,
  bold: Math::Function::FontStyle::Bold,
}.freeze

Class Method Summary collapse

Class Method Details

.accent_word?(string) ⇒ Boolean

True when string is a bare word naming an over/under accent. Such tokens are literal identifiers in MathML (the accent itself is a diacritic character inside <mover>/<munder>), so callers must not promote them to accent operators. AsciiMath/LaTeX word forms (bar(x), barx) are parsed elsewhere and never reach this predicate.

Returns:

  • (Boolean)


191
192
193
# File 'lib/plurimath/mathml/constants.rb', line 191

def self.accent_word?(string)
  ACCENT_WORDS.include?(string&.strip)
end