9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/metanorma/mirror/handlers/formula.rb', line 9
def self.call(element, context:)
attrs = Handlers.(element, extra_attrs: EXTRA)
stem = SafeAttr.read(element, :stem)
if stem
attrs[:stem_type] = SafeAttr.read(stem, :stem_type)
asciimath = SafeAttr.read(stem, :asciimath)
if asciimath&.value && !asciimath.value.strip.empty?
attrs[:asciimath] =
asciimath.value
end
math = SafeAttr.read(stem, :math)
attrs[:mathml] = MathUtil.mathml_from_math(math) if math
end
text = SafeAttr.read(element, :text)
attrs[:math_text] = Array(text).join if text && !attrs[:asciimath]
Handlers.build_node("formula", attrs: attrs.compact)
end
|