Class: Plurimath::Mathml::Translator

Inherits:
Object
  • Object
show all
Includes:
FormulaTransformation
Defined in:
lib/plurimath/mathml/translator.rb

Instance Method Summary collapse

Constructor Details

#initializeTranslator

Returns a new instance of Translator.



10
11
12
# File 'lib/plurimath/mathml/translator.rb', line 10

def initialize
  @memoized = {}
end

Instance Method Details

#mml_to_plurimath(mml_node) ⇒ Object

Main entry point: Mml model → Plurimath model



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/plurimath/mathml/translator.rb', line 15

def mml_to_plurimath(mml_node)
  return nil if mml_node.nil?

  case mml_node
  when String then text_node_to_plurimath(mml_node)
  when Mml::V4::Math then math_to_formula(mml_node)
  when Mml::V4::Mrow then mrow_to_mrow(mml_node)
  when Mml::V4::Mover then mover_to_overset(mml_node)
  when Mml::V4::Munder then munder_to_underset(mml_node)
  when Mml::V4::Munderover then munderover_to_underover(mml_node)
  when Mml::V4::Msup then msup_to_power(mml_node)
  when Mml::V4::Msub then msub_to_base(mml_node)
  when Mml::V4::Msubsup then msubsup_to_powerbase(mml_node)
  when Mml::V4::Mfrac then mfrac_to_frac(mml_node)
  when Mml::V4::Mfraction then mfrac_to_frac(mml_node)
  when Mml::V4::Msqrt then msqrt_to_sqrt(mml_node)
  when Mml::V4::Mroot then mroot_to_root(mml_node)
  when Mml::V4::Mi then mi_to_symbol(mml_node)
  when Mml::V4::Mo then mo_to_symbol(mml_node)
  when Mml::V4::Mn then mn_to_number(mml_node)
  when Mml::V4::Mtext then mtext_to_text(mml_node)
  when Mml::V4::Mstyle then mstyle_to_mstyle(mml_node)
  when Mml::V4::Mtable then mtable_to_table(mml_node)
  when Mml::V4::Mtr then mtr_to_tr(mml_node)
  when Mml::V4::Mtd then mtd_to_td(mml_node)
  when Mml::V4::Mfenced then mfenced_to_fenced(mml_node)
  when Mml::V4::Mphantom then mphantom_to_phantom(mml_node)
  when Mml::V4::Menclose then menclose_to_menclose(mml_node)
  when Mml::V4::Merror then merror_to_merror(mml_node)
  when Mml::V4::Mlongdiv then mlongdiv_to_longdiv(mml_node)
  when Mml::V4::Mstack then mstack_to_stackrel(mml_node)
  when Mml::V4::Msrow then msrow_to_formula(mml_node)
  when Mml::V4::Msgroup then msgroup_to_msgroup(mml_node)
  when Mml::V4::Msline then msline_to_msline(mml_node)
  when Mml::V4::Mpadded then mpadded_to_mpadded(mml_node)
  when Mml::V4::Mglyph then mglyph_to_mglyph(mml_node)
  when Mml::V4::Mmultiscripts then mmultiscripts_to_multiscript(mml_node)
  when Mml::V4::Mlabeledtr then mlabeledtr_to_mlabeledtr(mml_node)
  when Mml::V4::Semantics then semantics_to_semantics(mml_node)
  when Mml::V4::None then none_to_none
  when Mml::V4::Ms then ms_to_ms(mml_node)
  when Mml::V4::Mscarries then mscarries_to_scarries(mml_node)
  when Mml::V4::Mscarry then mscarry_to_mscarry(mml_node)
  when Mml::V4::Annotation then nil
  when Mml::V4::AnnotationXml then nil
  when Mml::V4::Malignmark then nil
  when Mml::V4::Maligngroup then nil
  when Mml::V4::Mspace then mspace_to_space(mml_node)
  when Mml::V4::Mprescripts then mprescripts_to_prescripts(mml_node)
  else
    raise "Unknown mml node type: #{mml_node.class}"
  end
end