Module: Plurimath::Mathml::FunctionTokenResolver

Included in:
Utility, Omml::Utility
Defined in:
lib/plurimath/mathml/utility.rb

Instance Method Summary collapse

Instance Method Details

#contextual_accent_from_token(value) ⇒ Object

Promotes an accent character to its function class. Callers must only use this from an accent position; elsewhere the character has to stay a plain symbol/text. Decode-then-encode normalizes both call sites: MathML passes an already-encoded "̃", OMML passes the raw U+0303.



10
11
12
13
14
15
16
17
# File 'lib/plurimath/mathml/utility.rb', line 10

def contextual_accent_from_token(value)
  return nil if value.nil?

  entity = string_to_html_entity(html_entity_to_unicode(value.to_s))
  function_name =
    Mathml::Constants::CONTEXTUAL_ACCENT_FUNCTIONS[entity.strip.to_sym]
  get_class(function_name).new if function_name
end