plurimath 0.9.9 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a2daf0b544efc26b15bd562db6b9ccea9fea08b6ad7b085d9315288b84deebc7
4
- data.tar.gz: 68f7fd796097cc9ad6163342c91ec9db4214edacfa2c0c27c06840e37c80523c
3
+ metadata.gz: 8cc764c51d0c686e8e45c0ebb2e2a50cd338c80981f2a6dbe3a1d0107fccec42
4
+ data.tar.gz: 4c49243889ed994074cead3cccb52d55b9228e0c9394406f5564e02c2b9971a5
5
5
  SHA512:
6
- metadata.gz: d1b5453cf0d8adbecd52d44c10fb98a509e0be7c70e89799e2a34c6a8418271f617143293b0424d9d1e14ca70be5ee8a821d2dfcdd68578be0b38e51b0b53d0f
7
- data.tar.gz: 106b39d4b3a77e4a4fbc3324c2418060696f731e7adf87fb3c2b4eeb5230e9914af1fb633e0125843472c7cc2cbeafcb7f6e63017dc632ab9a5288ec0c939a04
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
@@ -86,6 +86,7 @@ module Plurimath
86
86
 
87
87
  rule(:symbol_class_commands) do
88
88
  (str("&#x") >> match["0-9a-fA-F"].repeat >> str(";")).as(:unicode_symbols) |
89
+ str("\\;").as(:three_per_em_space) |
89
90
  hash_to_expression(Constants.symbols_constants) |
90
91
  under_over |
91
92
  environment |
@@ -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 { |val| val.to_asciimath(options: options) }.join(" ")
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.nodes, 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(nodes, prev_node)
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
- unitsml_post_processing(node.nodes, node) if node.nodes.none?(String)
657
+ unitsml_processing(node.nodes, node) if node.nodes.none?(String)
636
658
  end
637
659
  end
638
660
 
@@ -15,7 +15,9 @@ module Plurimath
15
15
  end
16
16
 
17
17
  def to_asciimath(options:)
18
- parameter_one.map { |val| val&.to_asciimath(options: options) }.join(" ")
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
@@ -25,7 +25,7 @@ module Plurimath
25
25
  end
26
26
 
27
27
  def to_mathml_without_math_tag(_, **)
28
- ox_element("mi") << "&#x2248;"
28
+ ox_element("mo") << "&#x2248;"
29
29
  end
30
30
 
31
31
  def to_omml_without_math_tag(_, **)
@@ -16,8 +16,8 @@ module Plurimath
16
16
  ","
17
17
  end
18
18
 
19
- def to_asciimath(**)
20
- ","
19
+ def to_asciimath(options:)
20
+ options[:table] ? "\",\"" : ","
21
21
  end
22
22
 
23
23
  def to_unicodemath(**)
@@ -0,0 +1,41 @@
1
+ module Plurimath
2
+ module Math
3
+ module Symbols
4
+ class ThreePerEmSpace < Symbol
5
+ INPUT = {
6
+ unicodemath: [["&#x2004;"], parsing_wrapper(["\\;"], lang: :unicode)],
7
+ asciimath: [[";", "&#x2004;"], parsing_wrapper(["\\;"], lang: :asciimath)],
8
+ mathml: ["&#x2004;"],
9
+ latex: [["\\;", "&#x2004;"]],
10
+ omml: ["&#x2004;"],
11
+ html: ["&#x2004;"],
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("&#x2004;")
25
+ end
26
+
27
+ def to_mathml_without_math_tag(_, **)
28
+ ox_element("mo") << "&#x2004;"
29
+ end
30
+
31
+ def to_omml_without_math_tag(_, **)
32
+ "&#x2004;"
33
+ end
34
+
35
+ def to_html(**)
36
+ "&#x2004;"
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Plurimath
4
- VERSION = "0.9.9"
4
+ VERSION = "0.9.10"
5
5
  end
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.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-08-12 00:00:00.000000000 Z
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