Class: Metanorma::Iso::Sts::Transformer::FormulaTransformer

Inherits:
Transformer::Base
  • Object
show all
Defined in:
lib/metanorma/iso/sts/transformer/formula_transformer.rb

Instance Method Summary collapse

Instance Method Details

#transform(formula) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/metanorma/iso/sts/transformer/formula_transformer.rb', line 7

def transform(formula)
  ::Sts::IsoSts::DispFormula.new do |f|
    f.id = id_for(formula)

    formula_label = label_for(formula)
    f.label = formula_label if formula_label

    if formula.stem
      stem = formula.stem
      if stem.math
        math_el = ::Sts::IsoSts::Mathml2::Math.new
        math_el.content = [stem.math.to_xml]
        f.math = math_el
      elsif stem.content
        tex = ::Sts::NisoSts::TexMath.new
        tex.content = [stem.content]
        f.tex_math = tex
      end
    end
  end
end