plurimath 0.9.8 → 0.9.10
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/latex/constants.rb +0 -18
- data/lib/plurimath/latex/parse.rb +1 -0
- data/lib/plurimath/latex/transform.rb +1 -0
- data/lib/plurimath/math/formula.rb +27 -5
- data/lib/plurimath/math/function/td.rb +16 -1
- data/lib/plurimath/math/symbols/approx.rb +1 -1
- data/lib/plurimath/math/symbols/comma.rb +2 -2
- data/lib/plurimath/math/symbols/three_per_em_space.rb +41 -0
- data/lib/plurimath/setup/ox_engine.rb +5 -0
- data/lib/plurimath/version.rb +1 -1
- data/lib/plurimath/xml_engine/{ox → ox_engine}/element.rb +1 -1
- data/lib/plurimath/xml_engine/{ox.rb → ox_engine.rb} +2 -3
- data/lib/plurimath.rb +1 -1
- metadata +6 -5
- data/lib/plurimath/setup/ox.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8cc764c51d0c686e8e45c0ebb2e2a50cd338c80981f2a6dbe3a1d0107fccec42
|
4
|
+
data.tar.gz: 4c49243889ed994074cead3cccb52d55b9228e0c9394406f5564e02c2b9971a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 350ff349aeff62bad3d1b34e0184ae79236eb9ecbcca2b8a45e14a9eb73eebf18fe2c01113af0ba0c905f7356cf4c8adf661ae7bbd167e51df217f342db079a4
|
7
|
+
data.tar.gz: c0bba84f880383d6509f5fb2fa0d843ad8feac38067f7387c5ecb1379d320b90821bd97d3259db72713ab71c5367783626ee74324a49b6fc70f42d885c886976
|
@@ -204,24 +204,6 @@ module Plurimath
|
|
204
204
|
"[": "[",
|
205
205
|
"]": "]",
|
206
206
|
}.freeze
|
207
|
-
SLASHED_SYMBOLS = %w[
|
208
|
-
backslash
|
209
|
-
langle
|
210
|
-
rangle
|
211
|
-
lfloor
|
212
|
-
rfloor
|
213
|
-
lbrace
|
214
|
-
rbrace
|
215
|
-
lbrack
|
216
|
-
rbrack
|
217
|
-
lceil
|
218
|
-
rceil
|
219
|
-
Vert
|
220
|
-
vert
|
221
|
-
|
|
222
|
-
}
|
223
|
-
{
|
224
|
-
].freeze
|
225
207
|
|
226
208
|
class << self
|
227
209
|
def symbols_constants
|
@@ -25,6 +25,7 @@ module Plurimath
|
|
25
25
|
rule(under_over: simple(:under_over)) { under_over }
|
26
26
|
rule(power_base: simple(:power_base)) { power_base }
|
27
27
|
rule(table_data: simple(:table_data)) { table_data }
|
28
|
+
rule(three_per_em_space: simple(:space)) { Math::Symbols::ThreePerEmSpace.new }
|
28
29
|
|
29
30
|
rule(intermediate_exp: simple(:int_exp)) { int_exp }
|
30
31
|
|
@@ -54,7 +54,9 @@ module Plurimath
|
|
54
54
|
|
55
55
|
def to_asciimath(formatter: nil, unitsml: {}, options: nil)
|
56
56
|
options ||= { formatter: formatter, unitsml: unitsml }.compact
|
57
|
-
value.map
|
57
|
+
output = value.map do |val|
|
58
|
+
val.to_asciimath(options: asciimath_table_options(options, val))
|
59
|
+
end.join(" ")
|
58
60
|
rescue
|
59
61
|
parse_error!(:asciimath)
|
60
62
|
end
|
@@ -83,7 +85,7 @@ module Plurimath
|
|
83
85
|
style = ox_element("mstyle", attributes: style_attrs)
|
84
86
|
Utility.update_nodes(style, mathml_content(intent, options: options))
|
85
87
|
Utility.update_nodes(math, [style])
|
86
|
-
unitsml_post_processing(math
|
88
|
+
unitsml_post_processing(math, style)
|
87
89
|
dump_nodes(math, indent: 2)
|
88
90
|
rescue
|
89
91
|
parse_error!(:mathml)
|
@@ -583,6 +585,12 @@ module Plurimath
|
|
583
585
|
|
584
586
|
protected
|
585
587
|
|
588
|
+
def asciimath_table_options(options, object)
|
589
|
+
return options unless options.key?(:table) && object.is_a?(Math::Symbols::Comma)
|
590
|
+
|
591
|
+
options.merge(literal_comma: true)
|
592
|
+
end
|
593
|
+
|
586
594
|
def update_temp_order(value, order_name)
|
587
595
|
return if value.nil? || value.empty?
|
588
596
|
|
@@ -624,7 +632,21 @@ module Plurimath
|
|
624
632
|
r_tag << ox_element("br")
|
625
633
|
end
|
626
634
|
|
627
|
-
def unitsml_post_processing(
|
635
|
+
def unitsml_post_processing(math, style)
|
636
|
+
if all_unitsml_nodes?(style)
|
637
|
+
style.nodes.first.remove_attr("unitsml")
|
638
|
+
else
|
639
|
+
unitsml_processing(math.nodes, math)
|
640
|
+
end
|
641
|
+
end
|
642
|
+
|
643
|
+
def all_unitsml_nodes?(style)
|
644
|
+
return false unless style.nodes.one?
|
645
|
+
|
646
|
+
style.nodes.first.attributes["unitsml"] == "true"
|
647
|
+
end
|
648
|
+
|
649
|
+
def unitsml_processing(nodes, prev_node)
|
628
650
|
insert_index = 0
|
629
651
|
nodes.each.with_index do |node, index|
|
630
652
|
if node[:unitsml]
|
@@ -632,7 +654,7 @@ module Plurimath
|
|
632
654
|
insert_index += 1
|
633
655
|
node.remove_attr("unitsml")
|
634
656
|
end
|
635
|
-
|
657
|
+
unitsml_processing(node.nodes, node) if node.nodes.none?(String)
|
636
658
|
end
|
637
659
|
end
|
638
660
|
|
@@ -842,7 +864,7 @@ module Plurimath
|
|
842
864
|
|
843
865
|
while iteration < nodes.length do
|
844
866
|
node = nodes[iteration]
|
845
|
-
next iteration += 1 unless node.nodes[0].is_a?(Plurimath::XmlEngine::
|
867
|
+
next iteration += 1 unless node.nodes[0].is_a?(Plurimath::XmlEngine::OxEngine::Element)
|
846
868
|
|
847
869
|
if DERIVATIVE_CONSTS.include?(node.nodes[0]&.nodes&.first)
|
848
870
|
iteration += 1
|
@@ -15,7 +15,9 @@ module Plurimath
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def to_asciimath(options:)
|
18
|
-
parameter_one.map
|
18
|
+
parameter_one.map do |val|
|
19
|
+
val&.to_asciimath(options: td_asciimath_options(options, val))
|
20
|
+
end.join(" ")
|
19
21
|
end
|
20
22
|
|
21
23
|
def to_mathml_without_math_tag(intent, options:)
|
@@ -105,6 +107,19 @@ module Plurimath
|
|
105
107
|
table = Table.new(sliced_result.map { |res| Tr.new(Array(Td.new(Array(res)))) })
|
106
108
|
self.parameter_one = [table]
|
107
109
|
end
|
110
|
+
|
111
|
+
private
|
112
|
+
|
113
|
+
def td_asciimath_options(options, object)
|
114
|
+
case object
|
115
|
+
when ::Plurimath::Math::Symbols::Comma
|
116
|
+
options.merge(literal_comma: true)
|
117
|
+
when ::Plurimath::Math::Formula
|
118
|
+
options.merge(table: true)
|
119
|
+
else
|
120
|
+
options
|
121
|
+
end
|
122
|
+
end
|
108
123
|
end
|
109
124
|
end
|
110
125
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Plurimath
|
2
|
+
module Math
|
3
|
+
module Symbols
|
4
|
+
class ThreePerEmSpace < Symbol
|
5
|
+
INPUT = {
|
6
|
+
unicodemath: [[" "], parsing_wrapper(["\\;"], lang: :unicode)],
|
7
|
+
asciimath: [[";", " "], parsing_wrapper(["\\;"], lang: :asciimath)],
|
8
|
+
mathml: [" "],
|
9
|
+
latex: [["\\;", " "]],
|
10
|
+
omml: [" "],
|
11
|
+
html: [" "],
|
12
|
+
}.freeze
|
13
|
+
|
14
|
+
# output methods
|
15
|
+
def to_latex(**)
|
16
|
+
"\\;"
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_asciimath(**)
|
20
|
+
parsing_wrapper("\\;", lang: :asciimath)
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_unicodemath(**)
|
24
|
+
Utility.html_entity_to_unicode(" ")
|
25
|
+
end
|
26
|
+
|
27
|
+
def to_mathml_without_math_tag(_, **)
|
28
|
+
ox_element("mo") << " "
|
29
|
+
end
|
30
|
+
|
31
|
+
def to_omml_without_math_tag(_, **)
|
32
|
+
" "
|
33
|
+
end
|
34
|
+
|
35
|
+
def to_html(**)
|
36
|
+
" "
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/plurimath/version.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "plurimath/xml_engine"
|
4
|
+
require "plurimath/xml_engine/ox_engine/element"
|
4
5
|
require "ox"
|
5
6
|
Ox.default_options = { encoding: "UTF-8" }
|
6
7
|
|
7
8
|
module Plurimath
|
8
9
|
module XmlEngine
|
9
|
-
class
|
10
|
+
class OxEngine
|
10
11
|
class << self
|
11
12
|
def new_element(name)
|
12
13
|
Element.new(name)
|
@@ -36,5 +37,3 @@ module Plurimath
|
|
36
37
|
end
|
37
38
|
end
|
38
39
|
end
|
39
|
-
|
40
|
-
require "plurimath/xml_engine/ox/element"
|
data/lib/plurimath.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.9.
|
4
|
+
version: 0.9.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ox
|
@@ -1522,6 +1522,7 @@ files:
|
|
1522
1522
|
- lib/plurimath/math/symbols/thermod.rb
|
1523
1523
|
- lib/plurimath/math/symbols/theta.rb
|
1524
1524
|
- lib/plurimath/math/symbols/third.rb
|
1525
|
+
- lib/plurimath/math/symbols/three_per_em_space.rb
|
1525
1526
|
- lib/plurimath/math/symbols/threedangle.rb
|
1526
1527
|
- lib/plurimath/math/symbols/threedotcolon.rb
|
1527
1528
|
- lib/plurimath/math/symbols/threeunderdot.rb
|
@@ -1771,7 +1772,7 @@ files:
|
|
1771
1772
|
- lib/plurimath/omml/transform.rb
|
1772
1773
|
- lib/plurimath/setup/oga.rb
|
1773
1774
|
- lib/plurimath/setup/opal.rb.erb
|
1774
|
-
- lib/plurimath/setup/
|
1775
|
+
- lib/plurimath/setup/ox_engine.rb
|
1775
1776
|
- lib/plurimath/unicode_math.rb
|
1776
1777
|
- lib/plurimath/unicode_math/constants.rb
|
1777
1778
|
- lib/plurimath/unicode_math/parse.rb
|
@@ -1794,8 +1795,8 @@ files:
|
|
1794
1795
|
- lib/plurimath/xml_engine/oga/element.rb
|
1795
1796
|
- lib/plurimath/xml_engine/oga/node.rb
|
1796
1797
|
- lib/plurimath/xml_engine/oga/wrapper.rb
|
1797
|
-
- lib/plurimath/xml_engine/
|
1798
|
-
- lib/plurimath/xml_engine/
|
1798
|
+
- lib/plurimath/xml_engine/ox_engine.rb
|
1799
|
+
- lib/plurimath/xml_engine/ox_engine/element.rb
|
1799
1800
|
- plurimath.gemspec
|
1800
1801
|
- supported_parens_list.adoc
|
1801
1802
|
- supported_symbols_list.adoc
|