plurimath 0.3.6 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/plurimath/math/formula.rb +9 -4
- data/lib/plurimath/mathml/parser.rb +4 -2
- data/lib/plurimath/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39522e32ac4e62af9eb862173a64e6e8650a9531bae27f321f25c6a1bc594e95
|
4
|
+
data.tar.gz: df5419195046dcf270cd4561c8cf3f9657536217a370d7a9aef150d7ca6aec72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a2c7880f03ba5d70c508b61f9c272be5a4780cbc5a30f56e142f7aa6798b5a8059051c6ecaf80ac9c209ab2cda977d55d7354f28e06e42c3dd439e3e96c0349
|
7
|
+
data.tar.gz: f2c0962524dc14232b0a48a4cd92015551f39603087bc42b08e73d0a3e66952ae2ab260f13166d159de378bd1757c24b0039a58d5b0fd129fb7be431f523e6a1
|
@@ -3,12 +3,17 @@
|
|
3
3
|
module Plurimath
|
4
4
|
module Math
|
5
5
|
class Formula < Core
|
6
|
-
attr_accessor :value, :left_right_wrapper
|
6
|
+
attr_accessor :value, :left_right_wrapper, :displaystyle
|
7
7
|
|
8
|
-
def initialize(
|
8
|
+
def initialize(
|
9
|
+
value = [],
|
10
|
+
left_right_wrapper = true,
|
11
|
+
displaystyle: true
|
12
|
+
)
|
9
13
|
@value = value.is_a?(Array) ? value : [value]
|
10
14
|
left_right_wrapper = false if @value.first.is_a?(Function::Left)
|
11
15
|
@left_right_wrapper = left_right_wrapper
|
16
|
+
@displaystyle = displaystyle
|
12
17
|
end
|
13
18
|
|
14
19
|
def ==(object)
|
@@ -20,12 +25,12 @@ module Plurimath
|
|
20
25
|
value.map(&:to_asciimath).join(" ")
|
21
26
|
end
|
22
27
|
|
23
|
-
def to_mathml
|
28
|
+
def to_mathml(display_style: displaystyle)
|
24
29
|
math_attrs = {
|
25
30
|
xmlns: "http://www.w3.org/1998/Math/MathML",
|
26
31
|
display: "block",
|
27
32
|
}
|
28
|
-
style_attrs = { displaystyle:
|
33
|
+
style_attrs = { displaystyle: display_style }
|
29
34
|
math = Utility.ox_element("math", attributes: math_attrs)
|
30
35
|
style = Utility.ox_element("mstyle", attributes: style_attrs)
|
31
36
|
Utility.update_nodes(style, mathml_content)
|
@@ -21,10 +21,12 @@ module Plurimath
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def parse
|
24
|
-
ox_nodes = Ox.load(text, strip_namespace: true)
|
25
|
-
|
24
|
+
ox_nodes = Ox.load(text, strip_namespace: true)
|
25
|
+
display_style = ox_nodes&.locate("*/mstyle/@displaystyle")&.first
|
26
|
+
nodes = parse_nodes(ox_nodes.nodes)
|
26
27
|
Math::Formula.new(
|
27
28
|
Transform.new.apply(nodes).flatten.compact,
|
29
|
+
displaystyle: display_style
|
28
30
|
)
|
29
31
|
end
|
30
32
|
|
data/lib/plurimath/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: plurimath
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parslet
|