46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/plurimath/cli.rb', line 46
def convert
input = options[:input]
input_string = options[:file_path] ? File.read(options[:file_path]) : input
warn_and_exit("missing generator argument --input or --file-input") unless input_string
input_format = options[:input_format]
output_format = options[:output_format]
formula = Plurimath::Math.parse(input_string, input_format)
return puts formula.to_display(output_format.to_sym) if YAML.safe_load(options[:math_rendering])
display_style = options[:display_style]
split = options[:split_on_linebreak]
style = display_style.to_s.empty? ? "true" : display_style
output_text = case output_format
when "unicodemath"
formula.to_unicodemath
when "asciimath"
formula.to_asciimath
when "mathml"
formula.to_mathml(display_style: style, split_on_linebreak: split)
when "latex"
formula.to_latex
when "omml"
formula.to_omml(display_style: style, split_on_linebreak: split)
else
warn_and_exit("Invalid output format: #{output_format}")
end
puts output_text
end
|