Class: Plurimath::Math::Function::Text
Instance Attribute Summary
#parameter_one
Instance Method Summary
collapse
#==, #class_name, #initialize, #value_to_asciimath
Instance Method Details
#parse_text(lang) ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/plurimath/math/function/text.rb', line 30
def parse_text(lang)
regex = %r{\\mbox\{(?<mbox>.{1,})\}|unicode\[:(?<unicode>\w{1,})\]}
parameter_one.gsub!(regex) do |_text|
last_match = Regexp.last_match
if ["mathml", "html"].include?(lang)
symbol_value(last_match[:unicode]) || last_match[:mbox]
else
last_match[:unicode] || last_match[:mbox]
end
end
end
|
#symbol_value(unicode) ⇒ Object
#to_asciimath ⇒ Object
9
10
11
|
# File 'lib/plurimath/math/function/text.rb', line 9
def to_asciimath
"\"#{parse_text('asciimath') || parameter_one}\""
end
|
#to_html ⇒ Object
26
27
28
|
# File 'lib/plurimath/math/function/text.rb', line 26
def to_html
parse_text("html") || parameter_one
end
|
#to_latex ⇒ Object
22
23
24
|
# File 'lib/plurimath/math/function/text.rb', line 22
def to_latex
parse_text("latex") || parameter_one
end
|
#to_mathml_without_math_tag ⇒ Object
13
14
15
|
# File 'lib/plurimath/math/function/text.rb', line 13
def to_mathml_without_math_tag
"<mtext>#{parse_text('mathml') || parameter_one}</mtext>"
end
|