plurimath 0.8.18 → 0.8.20

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 766097c1faa26dc82f8664fca18a302b52920df2fce4ec8395cf2f65d8a7d687
4
- data.tar.gz: 35cf1a6b6a0e87fa5404b3eea87927cd69da535deeebfcd49f8db5ce1aaba8e6
3
+ metadata.gz: 674b18bd19282809f8e45b8d14b8249e67d7a80ae73df51bd678b2d15658dc36
4
+ data.tar.gz: a08def1749cece90982daf3ee329aa8a0a363d22fccceda9d41952f5f5d80afe
5
5
  SHA512:
6
- metadata.gz: 7307ab95dc0d60e6fe65c939665e08ec59902527a454427956ee17e6d2c7bc207921e529ae107d51ec0f2a2a0909cd7da260943d277a03755efc34aa01edd2d0
7
- data.tar.gz: 6f050eb9cae6730e911ccae66afe0a4384ab0fade68810fa4fa176e15d5f37eef225f0b11c1409fcd10ed05e75cbf7aa6fdd10a4e18d85ab335dbb947c22d350
6
+ metadata.gz: 626a181a170618aab1033863339c9423c2b85d76baa6eca4dfb68b5fd5cb01f37714456dc023b565784256ecb8e4bb170708185fe29a2ff8cb089df26300c5e2
7
+ data.tar.gz: 228a1da3ed8378fcf82b2c894b1a056d83c03a2d88d40ed0059312937a2104280cdbeaf65801b2c2c35d0c4f573a318d6987eaecc29f57a99b7c732fb17b6c23
data/Gemfile CHANGED
@@ -11,5 +11,5 @@ gem 'equivalent-xml'
11
11
  gem 'opal-rspec', "~> 1.1.0a"
12
12
  gem 'oga'
13
13
  gem 'ox'
14
- gem "unitsml", "0.2.9"
14
+ gem "unitsml"
15
15
  gem "debug"
@@ -629,11 +629,11 @@ module Plurimath
629
629
  end
630
630
 
631
631
  def unitsml_post_processing(nodes, prev_node)
632
+ insert_index = 0
632
633
  nodes.each.with_index do |node, index|
633
634
  if node[:unitsml]
634
- pre_index = index - 1
635
- pre_node = nodes[pre_index] if pre_index.zero? || pre_index.positive?
636
- prev_node.insert_in_nodes(index, space_element(node)) if valid_previous?(pre_node)
635
+ prev_node.insert_in_nodes(index + insert_index, space_element(node))
636
+ insert_index += 1
637
637
  node.remove_attr("unitsml")
638
638
  end
639
639
  unitsml_post_processing(node.nodes, node) if node.nodes.none?(String)
@@ -648,19 +648,10 @@ module Plurimath
648
648
 
649
649
  def space_element(node)
650
650
  element = (ox_element("mo") << "&#x2062;")
651
- element[:rspace] = "thickmathspace" if text_in_tag?(node.xml_nodes.nodes)
651
+ element[:rspace] = "thickmathspace"
652
652
  element
653
653
  end
654
654
 
655
- def text_in_tag?(nodes)
656
- next_nodes = nodes.first.nodes
657
- if next_nodes.all?(String)
658
- Utility.html_entity_to_unicode(next_nodes.first).match?(/\p{L}|\p{N}/)
659
- else
660
- text_in_tag?(next_nodes)
661
- end
662
- end
663
-
664
655
  def negated_value?
665
656
  value.last.is_a?(Math::Symbols::Symbol) && value.last.value == "&#x338;"
666
657
  end
@@ -670,21 +661,6 @@ module Plurimath
670
661
  value&.map { |v| v.to_unicodemath(options: options) }&.join(join_str)
671
662
  end
672
663
 
673
- def valid_previous?(previous)
674
- return unless previous
675
-
676
- ["mi", "mn"].include?(previous.name) ||
677
- inside_tag?(previous)
678
- end
679
-
680
- def inside_tag?(previous)
681
- previous&.nodes&.any? do |node|
682
- next if node.is_a?(String)
683
-
684
- valid_previous?(node) if node.xml_node?
685
- end
686
- end
687
-
688
664
  def intent_attribute(mathml)
689
665
  return unless mathml || value.length != 2
690
666
  return unless valid_first_parameter?(value.first)
@@ -108,7 +108,10 @@ module Plurimath
108
108
  end
109
109
 
110
110
  def t_tag(options:)
111
- Utility.ox_element("t", namespace: "m") << (value || to_omml_without_math_tag(nil, options: options))
111
+ output = value || to_omml_without_math_tag(nil, options: options)
112
+ return t_element unless output
113
+
114
+ t_element << output
112
115
  end
113
116
 
114
117
  def separate_table
@@ -158,6 +161,10 @@ module Plurimath
158
161
 
159
162
  private
160
163
 
164
+ def t_element
165
+ Utility.ox_element("t", namespace: "m")
166
+ end
167
+
161
168
  def explicit_checks(unicode)
162
169
  return true if [unicode, value].any? { |v| ["∣", "|"].include?(v) }
163
170
  return true if unicode_const(:ACCENT_SYMBOLS).has_value?(value)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Plurimath
4
- VERSION = "0.8.18"
4
+ VERSION = "0.8.20"
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.8.18
4
+ version: 0.8.20
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-12-16 00:00:00.000000000 Z
11
+ date: 2025-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ox