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",
  "ς": "varsigma",
  "σ": "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
CONTEXTUAL_ACCENT_FUNCTIONS =

Accent characters promoted to their function class ONLY in an accent position (MathML , OMML <m:acc>). Kept separate from UNICODE_SYMBOLS because Text#value= consumes that map as a global substitution table, so an entry there would also rewrite the character inside ordinary text runs and bare tokens.

{
  "&#x303;": "tilde",
}.freeze
SYMBOLS =
{
  "|": "|",
  "/": "//",
  "\\": "\\\\",
  "~": "tilde",
  "(": "(",
  ")": ")",
  "(:": "(:",
  ":)": ":)",
  "{": "{",
  "}": "}",
  "{:": "{:",
  ":}": ":}",
  "]": "]",
  "[": "[",
  "=": "=",
  "+": "+",
  "-": "-",
}.freeze
NAMED_FUNCTION_WORDS =

Named operators that have no dedicated MathML/OMML representation — no unicode character and no structural element — so a bare //<m:t> word (e.g. sin, <m:t>min</m:t>) is their only written form and resolves to the function class. Every other CLASSES entry has a proper form — a diacritic character (bar/hat/vec via ), a unicode symbol (sum/prod/int via ∑ etc.), or a structural element (frac via /<m:f>, sqrt via ) — so its bare word is a literal identifier, not the function. See PR #450 (which introduced this for accents).

%w[
  arccos arcsin arctan sin cos tan sec csc cot sinh cosh tanh coth sech
  csch log ln exp det dim gcd lcm glb lub max min mod
].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
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

.named_function_word?(string) ⇒ Boolean

True when string is a bare word naming an operator that has no other MathML/OMML representation, so it legitimately resolves to its function class. Words for constructs that DO have a character/structural form (accents, sum/prod/int, frac/sqrt/...) return false and stay literal.

Returns:



204
205
206
# File 'lib/plurimath/mathml/constants.rb', line 204

def self.named_function_word?(string)
  NAMED_FUNCTION_WORDS.include?(string&.strip)
end