plurimath 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +36 -0
- data/.rubocop.yml +2 -0
- data/lib/plurimath/asciimath/constants.rb +308 -0
- data/lib/plurimath/asciimath/parse.rb +87 -0
- data/lib/plurimath/asciimath/parser.rb +24 -0
- data/lib/plurimath/asciimath/transform.rb +304 -0
- data/lib/plurimath/asciimath.rb +16 -0
- data/lib/plurimath/html.rb +15 -0
- data/lib/plurimath/latex/constants.rb +1963 -0
- data/lib/plurimath/latex/parse.rb +105 -0
- data/lib/plurimath/latex/parser.rb +24 -0
- data/lib/plurimath/latex/transform.rb +298 -0
- data/lib/plurimath/latex.rb +15 -0
- data/lib/plurimath/math/formula.rb +43 -0
- data/lib/plurimath/math/function/abs.rb +12 -0
- data/lib/plurimath/math/function/arccos.rb +12 -0
- data/lib/plurimath/math/function/arcsin.rb +12 -0
- data/lib/plurimath/math/function/arctan.rb +12 -0
- data/lib/plurimath/math/function/bar.rb +16 -0
- data/lib/plurimath/math/function/base.rb +30 -0
- data/lib/plurimath/math/function/binary_function.rb +53 -0
- data/lib/plurimath/math/function/cancel.rb +12 -0
- data/lib/plurimath/math/function/ceil.rb +12 -0
- data/lib/plurimath/math/function/color.rb +23 -0
- data/lib/plurimath/math/function/cos.rb +12 -0
- data/lib/plurimath/math/function/cosh.rb +12 -0
- data/lib/plurimath/math/function/cot.rb +12 -0
- data/lib/plurimath/math/function/coth.rb +12 -0
- data/lib/plurimath/math/function/csc.rb +12 -0
- data/lib/plurimath/math/function/csch.rb +12 -0
- data/lib/plurimath/math/function/ddot.rb +12 -0
- data/lib/plurimath/math/function/deg.rb +12 -0
- data/lib/plurimath/math/function/det.rb +12 -0
- data/lib/plurimath/math/function/dim.rb +12 -0
- data/lib/plurimath/math/function/dot.rb +12 -0
- data/lib/plurimath/math/function/exp.rb +12 -0
- data/lib/plurimath/math/function/f.rb +12 -0
- data/lib/plurimath/math/function/fenced.rb +22 -0
- data/lib/plurimath/math/function/floor.rb +12 -0
- data/lib/plurimath/math/function/font_style.rb +45 -0
- data/lib/plurimath/math/function/frac.rb +23 -0
- data/lib/plurimath/math/function/g.rb +12 -0
- data/lib/plurimath/math/function/gcd.rb +12 -0
- data/lib/plurimath/math/function/glb.rb +12 -0
- data/lib/plurimath/math/function/hat.rb +12 -0
- data/lib/plurimath/math/function/hom.rb +12 -0
- data/lib/plurimath/math/function/inf.rb +18 -0
- data/lib/plurimath/math/function/int.rb +17 -0
- data/lib/plurimath/math/function/ker.rb +12 -0
- data/lib/plurimath/math/function/lcm.rb +12 -0
- data/lib/plurimath/math/function/left.rb +23 -0
- data/lib/plurimath/math/function/lg.rb +12 -0
- data/lib/plurimath/math/function/lim.rb +23 -0
- data/lib/plurimath/math/function/liminf.rb +12 -0
- data/lib/plurimath/math/function/limits.rb +19 -0
- data/lib/plurimath/math/function/limsup.rb +12 -0
- data/lib/plurimath/math/function/ln.rb +12 -0
- data/lib/plurimath/math/function/log.rb +23 -0
- data/lib/plurimath/math/function/lub.rb +12 -0
- data/lib/plurimath/math/function/max.rb +12 -0
- data/lib/plurimath/math/function/min.rb +12 -0
- data/lib/plurimath/math/function/mod.rb +23 -0
- data/lib/plurimath/math/function/norm.rb +15 -0
- data/lib/plurimath/math/function/obrace.rb +12 -0
- data/lib/plurimath/math/function/oint.rb +17 -0
- data/lib/plurimath/math/function/overset.rb +23 -0
- data/lib/plurimath/math/function/power.rb +30 -0
- data/lib/plurimath/math/function/power_base.rb +26 -0
- data/lib/plurimath/math/function/prod.rb +23 -0
- data/lib/plurimath/math/function/root.rb +22 -0
- data/lib/plurimath/math/function/sec.rb +12 -0
- data/lib/plurimath/math/function/sech.rb +12 -0
- data/lib/plurimath/math/function/sin.rb +12 -0
- data/lib/plurimath/math/function/sinh.rb +12 -0
- data/lib/plurimath/math/function/sqrt.rb +16 -0
- data/lib/plurimath/math/function/stackrel.rb +12 -0
- data/lib/plurimath/math/function/substack.rb +18 -0
- data/lib/plurimath/math/function/sum.rb +23 -0
- data/lib/plurimath/math/function/sup.rb +12 -0
- data/lib/plurimath/math/function/table.rb +42 -0
- data/lib/plurimath/math/function/tan.rb +12 -0
- data/lib/plurimath/math/function/tanh.rb +12 -0
- data/lib/plurimath/math/function/td.rb +27 -0
- data/lib/plurimath/math/function/ternary_function.rb +42 -0
- data/lib/plurimath/math/function/text.rb +32 -0
- data/lib/plurimath/math/function/tilde.rb +12 -0
- data/lib/plurimath/math/function/tr.rb +25 -0
- data/lib/plurimath/math/function/ubrace.rb +12 -0
- data/lib/plurimath/math/function/ul.rb +12 -0
- data/lib/plurimath/math/function/unary_function.rb +41 -0
- data/lib/plurimath/math/function/underover.rb +12 -0
- data/lib/plurimath/math/function/underset.rb +12 -0
- data/lib/plurimath/math/function/vec.rb +12 -0
- data/lib/plurimath/math/function.rb +3 -0
- data/lib/plurimath/math/number.rb +29 -0
- data/lib/plurimath/math/symbol.rb +34 -0
- data/lib/plurimath/math.rb +51 -0
- data/lib/plurimath/mathml/constants.rb +327 -0
- data/lib/plurimath/mathml/parse.rb +63 -0
- data/lib/plurimath/mathml/parser.rb +25 -0
- data/lib/plurimath/mathml/transform.rb +195 -0
- data/lib/plurimath/mathml.rb +16 -0
- data/lib/plurimath/omml.rb +15 -0
- data/lib/plurimath/unicode.rb +15 -0
- data/lib/plurimath/unitsml.rb +11 -0
- data/lib/plurimath/version.rb +3 -1
- data/lib/plurimath.rb +3 -5
- data/plurimath.gemspec +3 -3
- metadata +129 -11
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "ternary_function"
|
4
|
+
|
5
|
+
module Plurimath
|
6
|
+
module Math
|
7
|
+
module Function
|
8
|
+
class Fenced < TernaryFunction
|
9
|
+
def to_asciimath
|
10
|
+
first_value = parameter_one ? parameter_one.to_asciimath : "("
|
11
|
+
second_value = parameter_two.map(&:to_asciimath).join(",") if parameter_two
|
12
|
+
third_value = parameter_three ? parameter_three.to_asciimath : ")"
|
13
|
+
"#{first_value}#{second_value}#{third_value}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_mathml_without_math_tag
|
17
|
+
"<mfenced open='#{parameter_one.value}' close='#{parameter_three.value}'>#{parameter_two.map(&:to_mathml_without_math_tag).join}</mfenced>"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "binary_function"
|
4
|
+
|
5
|
+
module Plurimath
|
6
|
+
module Math
|
7
|
+
module Function
|
8
|
+
class FontStyle < BinaryFunction
|
9
|
+
FONT_TYPES = {
|
10
|
+
mathfrak: "fraktur",
|
11
|
+
mathcal: "script",
|
12
|
+
mathbb: "double-struck",
|
13
|
+
mathsf: "sans-serif",
|
14
|
+
mathtt: "monospace",
|
15
|
+
mathbf: "bold",
|
16
|
+
bbb: "double-struck",
|
17
|
+
bb: "bold",
|
18
|
+
fr: "fraktur",
|
19
|
+
cc: "script",
|
20
|
+
sf: "sans-serif",
|
21
|
+
tt: "monospace",
|
22
|
+
}.freeze
|
23
|
+
|
24
|
+
def to_asciimath
|
25
|
+
if Asciimath::Constants::FONT_STYLES.include?(parameter_two.to_sym)
|
26
|
+
"#{parameter_two}(#{parameter_one.to_asciimath})"
|
27
|
+
else
|
28
|
+
parameter_one.to_asciimath
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def to_mathml_without_math_tag
|
33
|
+
type = FONT_TYPES[parameter_two.to_sym]
|
34
|
+
first_value = parameter_one.to_mathml_without_math_tag
|
35
|
+
"<mstyle mathvariant='#{type}'>#{first_value}</mstyle>"
|
36
|
+
end
|
37
|
+
|
38
|
+
def to_latex
|
39
|
+
first_value = parameter_one.to_latex if parameter_one
|
40
|
+
"\\#{parameter_two}{#{first_value}}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "binary_function"
|
4
|
+
|
5
|
+
module Plurimath
|
6
|
+
module Math
|
7
|
+
module Function
|
8
|
+
class Frac < BinaryFunction
|
9
|
+
def to_mathml_without_math_tag
|
10
|
+
first_value = parameter_one.to_mathml_without_math_tag if parameter_one
|
11
|
+
two_value = parameter_two.to_mathml_without_math_tag if parameter_two
|
12
|
+
"<mfrac>#{first_value}#{two_value}</mfrac>"
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_latex
|
16
|
+
first_value = parameter_one.to_latex if parameter_one
|
17
|
+
two_value = parameter_two.to_latex if parameter_two
|
18
|
+
"\\frac{#{first_value}}{#{two_value}}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "binary_function"
|
4
|
+
|
5
|
+
module Plurimath
|
6
|
+
module Math
|
7
|
+
module Function
|
8
|
+
class Inf < BinaryFunction
|
9
|
+
|
10
|
+
def to_latex
|
11
|
+
first_value = "_{#{parameter_one.to_latex}}" if parameter_one
|
12
|
+
second_value = "^{#{parameter_two.to_latex}}" if parameter_two
|
13
|
+
"\\#{class_name}#{first_value}#{second_value}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "binary_function"
|
4
|
+
|
5
|
+
module Plurimath
|
6
|
+
module Math
|
7
|
+
module Function
|
8
|
+
class Int < BinaryFunction
|
9
|
+
def to_asciimath
|
10
|
+
first_value = "_(#{parameter_one.to_asciimath})" if parameter_one
|
11
|
+
second_value = "^(#{parameter_two.to_asciimath})" if parameter_two
|
12
|
+
"int#{first_value}#{second_value}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "unary_function"
|
4
|
+
|
5
|
+
module Plurimath
|
6
|
+
module Math
|
7
|
+
module Function
|
8
|
+
class Left < UnaryFunction
|
9
|
+
def to_asciimath
|
10
|
+
"left#{value_to_asciimath}"
|
11
|
+
end
|
12
|
+
|
13
|
+
def value_to_asciimath
|
14
|
+
"(#{parameter_one.to_asciimath}right)" if parameter_one
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_latex
|
18
|
+
"\\left(#{parameter_one&.to_latex}\\right)"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "binary_function"
|
4
|
+
|
5
|
+
module Plurimath
|
6
|
+
module Math
|
7
|
+
module Function
|
8
|
+
class Lim < BinaryFunction
|
9
|
+
def to_asciimath
|
10
|
+
first_value = "_(#{parameter_one.to_asciimath})" if parameter_one
|
11
|
+
second_value = "^(#{parameter_two.to_asciimath})" if parameter_two
|
12
|
+
"lim#{first_value}#{second_value}"
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_latex
|
16
|
+
first_value = "_{#{parameter_one.to_latex}}" if parameter_one
|
17
|
+
second_value = "^{#{parameter_two.to_latex}}" if parameter_two
|
18
|
+
"\\#{class_name}#{first_value}#{second_value}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "ternary_function"
|
4
|
+
|
5
|
+
module Plurimath
|
6
|
+
module Math
|
7
|
+
module Function
|
8
|
+
class Limits < TernaryFunction
|
9
|
+
|
10
|
+
def to_latex
|
11
|
+
first_value = parameter_one&.to_latex
|
12
|
+
second_value = "{#{parameter_two.to_latex}}" if parameter_two
|
13
|
+
third_value = "{#{parameter_three.to_latex}}" if parameter_three
|
14
|
+
"#{first_value}\\#{class_name}_#{second_value}^#{third_value}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "binary_function"
|
4
|
+
|
5
|
+
module Plurimath
|
6
|
+
module Math
|
7
|
+
module Function
|
8
|
+
class Log < BinaryFunction
|
9
|
+
def to_asciimath
|
10
|
+
first_value = "_(#{parameter_one.to_asciimath})" if parameter_one
|
11
|
+
second_value = "^(#{parameter_two.to_asciimath})" if parameter_two
|
12
|
+
"log#{first_value}#{second_value}"
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_latex
|
16
|
+
first_value = "_{#{parameter_one.to_latex}}" if parameter_one
|
17
|
+
second_value = "^{#{parameter_two.to_latex}}" if parameter_two
|
18
|
+
"\\log#{first_value}#{second_value}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "binary_function"
|
4
|
+
|
5
|
+
module Plurimath
|
6
|
+
module Math
|
7
|
+
module Function
|
8
|
+
class Mod < BinaryFunction
|
9
|
+
def to_asciimath
|
10
|
+
first_value = "(#{parameter_one.to_asciimath})" if parameter_one
|
11
|
+
second_value = "(#{parameter_two.to_asciimath})" if parameter_two
|
12
|
+
"#{first_value}mod#{second_value}"
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_latex
|
16
|
+
first_value = "{#{parameter_one.to_latex}}" if parameter_one
|
17
|
+
second_value = "{#{parameter_two.to_latex}}" if parameter_two
|
18
|
+
"#{first_value}\\pmod#{second_value}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "unary_function"
|
4
|
+
|
5
|
+
module Plurimath
|
6
|
+
module Math
|
7
|
+
module Function
|
8
|
+
class Norm < UnaryFunction
|
9
|
+
def to_mathml_without_math_tag
|
10
|
+
"<mo>∥</mo>#{parameter_one.to_mathml_without_math_tag}<mo>∥</mo>"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "binary_function"
|
4
|
+
|
5
|
+
module Plurimath
|
6
|
+
module Math
|
7
|
+
module Function
|
8
|
+
class Oint < BinaryFunction
|
9
|
+
def to_asciimath
|
10
|
+
first_value = "_(#{parameter_one.to_asciimath})" if parameter_one
|
11
|
+
second_value = "^(#{parameter_two.to_asciimath})" if parameter_two
|
12
|
+
"oint#{first_value}#{second_value}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|