plurimath 0.8.1 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/plurimath/asciimath/transform.rb +5 -0
- data/lib/plurimath/math/formula.rb +19 -15
- data/lib/plurimath/mathml/transform.rb +6 -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: f961f580d6f46c943b805f8c2f2a77281151ddcb76eab4a7e7adabbfe61b2b6b
|
4
|
+
data.tar.gz: fbe6a5651b11576a161fe0620780aa359151688d97fac674874679d138c8c34d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: badfd5bd7eb9f2b84ef7604c21ab4f82fa93de5c52df760ee2fcc7ade85cd6900dbc527d41faf2c2521ae6dfbeb2cf79f8af0028927c6a1049bd921836fdec41
|
7
|
+
data.tar.gz: 886be496741ca30633f2ca6d25a5d39f1e5986065adb07cbc961a08ebb6fc04f4d060037afaafec59fb4fbcc5510c968aa1b06bfec366388d7bab1eaad2add99
|
@@ -896,6 +896,11 @@ module Plurimath
|
|
896
896
|
Math::Formula.new([table] + expr.flatten.compact)
|
897
897
|
end
|
898
898
|
|
899
|
+
rule(table: simple(:table),
|
900
|
+
left_right: simple(:left_right)) do
|
901
|
+
Math::Formula.new([table, left_right])
|
902
|
+
end
|
903
|
+
|
899
904
|
rule(table: simple(:table),
|
900
905
|
expr: simple(:expr)) do
|
901
906
|
formula_array = [table]
|
@@ -288,26 +288,19 @@ module Plurimath
|
|
288
288
|
|
289
289
|
def unitsml_post_processing(nodes)
|
290
290
|
nodes.each.with_index do |node, index|
|
291
|
-
if node.is_a?(Ox::Element) && node
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
else
|
297
|
-
nodes.insert(index, space_element)
|
298
|
-
end
|
299
|
-
end
|
300
|
-
|
301
|
-
node.attributes.delete_if {|k, v| k == :unitsml }
|
291
|
+
if node.is_a?(Ox::Element) && node&.attributes&.dig(:unitsml)
|
292
|
+
pre_index = index - 1
|
293
|
+
pre_node = nodes[pre_index] if pre_index.zero? || pre_index.positive?
|
294
|
+
nodes.insert(index, space_element(node)) if valid_previous?(pre_node)
|
295
|
+
node.attributes.delete_if { |k, _| k == :unitsml }
|
302
296
|
end
|
303
|
-
|
304
|
-
unitsml_post_processing(node.nodes) if !node.nodes.any?(String)
|
297
|
+
unitsml_post_processing(node.nodes) if node.nodes.none?(String)
|
305
298
|
end
|
306
299
|
end
|
307
300
|
|
308
|
-
def space_element(
|
301
|
+
def space_element(node)
|
309
302
|
element = (ox_element("mo") << "⁢")
|
310
|
-
element.attributes[:rspace] = "thickmathspace" if
|
303
|
+
element.attributes[:rspace] = "thickmathspace" if text_in_tag?(node.nodes)
|
311
304
|
element
|
312
305
|
end
|
313
306
|
|
@@ -327,6 +320,17 @@ module Plurimath
|
|
327
320
|
def unicodemath_value
|
328
321
|
(negated_value? || mini_sized?) ? value&.map(&:to_unicodemath)&.join : value&.map(&:to_unicodemath)&.join(" ")
|
329
322
|
end
|
323
|
+
|
324
|
+
def valid_previous?(previous)
|
325
|
+
return unless previous
|
326
|
+
|
327
|
+
["mi", "mn"].include?(previous.name) ||
|
328
|
+
inside_tag?(previous)
|
329
|
+
end
|
330
|
+
|
331
|
+
def inside_tag?(previous)
|
332
|
+
previous&.nodes&.any? { |node| valid_previous?(node) if node.is_a?(Ox::Element) }
|
333
|
+
end
|
330
334
|
end
|
331
335
|
end
|
332
336
|
end
|
@@ -191,8 +191,12 @@ module Plurimath
|
|
191
191
|
elsif flatten_mrow&.first&.is_nary_function? && flatten_mrow.length == 2
|
192
192
|
nary_function = flatten_mrow.first
|
193
193
|
if nary_function.is_ternary_function? && nary_function.all_values_exist?
|
194
|
-
|
195
|
-
|
194
|
+
if nary_function.respond_to?(:new_nary_function)
|
195
|
+
flatten_mrow[0] = nary_function.new_nary_function(flatten_mrow.delete_at(1))
|
196
|
+
flatten_mrow
|
197
|
+
else
|
198
|
+
Utility.filter_values(flatten_mrow)
|
199
|
+
end
|
196
200
|
elsif nary_function.is_binary_function? && nary_function.any_value_exist?
|
197
201
|
flatten_mrow[0] = nary_function.new_nary_function(flatten_mrow.delete_at(1))
|
198
202
|
flatten_mrow
|
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.8.
|
4
|
+
version: 0.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-04-
|
11
|
+
date: 2024-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parslet
|