plurimath 0.4.3 → 0.4.4

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: d69a05ccfdd97b4b313df9c6bec1682ab39078adbb43c8823880f90df142f6f1
4
- data.tar.gz: 441f919b29159720405b0bd685405e8ecb527a2716c0ac1427fff3c11575fa22
3
+ metadata.gz: d4c3f2e8fb24ec72671101a001b6a359f1bf678a19b229f7238c7e250bb2689b
4
+ data.tar.gz: 1899fb80d23b9145c6a9b61d4fec13d521b3abadf57f81201101ad32b166b816
5
5
  SHA512:
6
- metadata.gz: f97960509050b66f88da2d6bb7b5f5466d6a2b0d51e06ad63322e39859aa84416a4996ae6df3403dffc838ac2d14edcb5f707fec3b4607b0ce367c13cf0df1eb
7
- data.tar.gz: 1e7e533e85719d23428cdaad2aa218692802a20525059b6cd99951a0b63fffb2f00b4c6325f39bc039056f99c4ea72a80cb8a7660aebde916520f992ae69c5ea
6
+ metadata.gz: 57dd9fc70c73e8e29209dce21f08dcc4ab16473cf155cf29f19560bfabb0680ca22c4e337b0d766057c6357e24aae1f55a1965f79c881ead796d69730b153337
7
+ data.tar.gz: c16720307e808c0e7efe6435302b622aab66ec7dcc2a4df95a898d6b637a834464fd500e33362398033ed1422b3059db63e8577e267a68fbfb09007738af0623
@@ -3783,6 +3783,7 @@ module Plurimath
3783
3783
  UNDEROVER_CLASSES = %w[
3784
3784
  bmod
3785
3785
  pmod
3786
+ mod
3786
3787
  ].freeze
3787
3788
  LEFT_RIGHT_PARENTHESIS = {
3788
3789
  "\\backslash": "\",
@@ -15,7 +15,12 @@ module Plurimath
15
15
  end
16
16
 
17
17
  rule(:begining) do
18
- (slash >> str("begin") >> (str("{") >> symbol_text_or_integer >> str("*").as(:asterisk).maybe >> str("}")) >> optional_args)
18
+ (slash >> str("begin") >> (str("{") >> symbol_text_or_integer >> str("*").as(:asterisk) >> str("}")) >> optional_args.maybe) |
19
+ (slash >> str("begin") >> (str("{") >> symbol_text_or_integer >> str("}")))
20
+ end
21
+
22
+ rule(:array_begin) do
23
+ (str("\\begin{") >> str("array").as(:environment) >> str("}"))
19
24
  end
20
25
 
21
26
  rule(:ending) do
@@ -91,7 +96,8 @@ module Plurimath
91
96
  match["a-zA-Z"].as(:symbols) |
92
97
  match(/\d+(\.[0-9]+)|\d/).repeat(1).as(:number) |
93
98
  (str("\\\\").as("\\\\") >> match(/\s/).repeat) |
94
- str("\\ ").as(:space)
99
+ str("\\ ").as(:space) |
100
+ (str("\\operatorname{") >> match("[^}]").repeat.as(:symbols) >> str("}"))
95
101
  end
96
102
 
97
103
  rule(:intermediate_exp) do
@@ -133,7 +139,7 @@ module Plurimath
133
139
  (left_right.as(:left_right) >> base >> intermediate_exp.as(:subscript)) |
134
140
  left_right.as(:left_right) |
135
141
  (slash >> str("substack").as(:substack) >> intermediate_exp) |
136
- (begining >> array_args >> expression.as(:table_data) >> ending).as(:environment) |
142
+ (array_begin >> array_args >> expression.as(:table_data) >> ending).as(:environment) |
137
143
  (begining >> expression.as(:table_data) >> ending).as(:environment) |
138
144
  (slash >> environment >> intermediate_exp).as(:table_data) |
139
145
  power_base |
@@ -275,6 +275,14 @@ module Plurimath
275
275
  )
276
276
  end
277
277
 
278
+ rule(operant: simple(:operant),
279
+ supscript: simple(:supscript)) do
280
+ Math::Function::Power.new(
281
+ Math::Symbol.new(operant),
282
+ supscript,
283
+ )
284
+ end
285
+
278
286
  rule(sequence: simple(:sequence),
279
287
  expression: simple(:expr)) do
280
288
  [sequence, expr].compact
@@ -446,6 +454,14 @@ module Plurimath
446
454
  )
447
455
  end
448
456
 
457
+ rule(intermediate_exp: simple(:int_exp),
458
+ subscript: simple(:subscript)) do
459
+ Math::Function::Base.new(
460
+ int_exp,
461
+ subscript,
462
+ )
463
+ end
464
+
449
465
  rule(unicode_symbols: simple(:sym),
450
466
  subscript: simple(:subscript)) do
451
467
  Math::Function::Base.new(
@@ -139,6 +139,7 @@ module Plurimath
139
139
  def nary_tag_able?(display_style)
140
140
  value.length == 2 &&
141
141
  ["underover", "powerbase"].include?(value&.first&.class_name) &&
142
+ !value.first.parameter_one.is_a?(Function::FontStyle) &&
142
143
  (
143
144
  value&.first&.parameter_one&.to_omml_without_math_tag(display_style)&.length == 1 ||
144
145
  value&.first&.parameter_one.to_omml_without_math_tag(display_style).match?(/^&#x\w*\d*;$/)
@@ -84,6 +84,7 @@ module Plurimath
84
84
 
85
85
  def latex_paren(paren)
86
86
  return "" if paren.nil? || paren.empty?
87
+ return paren.gsub(":", "") if paren.include?(":") && ["{:", ":}"].include?(paren)
87
88
 
88
89
  paren = %w[{ }].include?(paren) ? "\\#{paren}" : paren
89
90
  paren = "\\#{Latex::Constants::UNICODE_SYMBOLS.invert[paren]}" if paren&.to_s&.match?(/&#x.{0,4};/)
@@ -8,8 +8,10 @@ module Plurimath
8
8
  class Sqrt < UnaryFunction
9
9
  def to_mathml_without_math_tag
10
10
  sqrt_tag = Utility.ox_element("msqrt")
11
- first_value = parameter_one&.to_mathml_without_math_tag
12
- sqrt_tag << first_value if first_value
11
+ Utility.update_nodes(
12
+ sqrt_tag,
13
+ Array(parameter_one&.to_mathml_without_math_tag),
14
+ )
13
15
  sqrt_tag
14
16
  end
15
17
 
@@ -108,6 +108,7 @@ module Plurimath
108
108
  "&#x2032;": "'",
109
109
  "&#xa0;&#xa0;": "quad",
110
110
  "&#xa0;&#xa0;&#xa0;&#xa0;": "qquad",
111
+ "&#x203e;": "overline",
111
112
  "&#x2322;": "frown",
112
113
  "&#x22ef;": "cdots",
113
114
  "&#x22ee;": "vdots",
@@ -12,7 +12,6 @@ module Plurimath
12
12
  rule(val: simple(:val)) { val }
13
13
  rule(scr: simple(:scr)) { scr }
14
14
  rule(sty: simple(:sty)) { sty }
15
- rule(dPr: subtree(:dpr)) { dpr }
16
15
  rule(num: subtree(:num)) { num }
17
16
  rule(den: subtree(:den)) { den }
18
17
  rule(fPr: subtree(:fPr)) { nil }
@@ -22,7 +21,6 @@ module Plurimath
22
21
  rule(deg: sequence(:deg)) { Utility.filter_values(deg) }
23
22
  rule(sub: sequence(:sub)) { Utility.filter_values(sub) }
24
23
  rule(sup: sequence(:sup)) { Utility.filter_values(sup) }
25
- rule(mtd: sequence(:mtd)) { mtd.flatten.compact }
26
24
  rule(boxPr: subtree(:box)) { nil }
27
25
  rule(argPr: subtree(:arg)) { nil }
28
26
  rule(accPr: subtree(:acc)) { acc.flatten.compact }
@@ -107,12 +105,28 @@ module Plurimath
107
105
  )
108
106
  end
109
107
 
108
+ rule(dPr: subtree(:dpr)) do
109
+ dpr.reject! { |d| d.is_a?(Hash) }
110
+ dpr
111
+ end
112
+
113
+ rule(mtd: sequence(:mtd)) do
114
+ flatten_mtd = mtd&.flatten&.compact
115
+ if flatten_mtd.length > 1 && !flatten_mtd.first.is_a?(Math::Core)
116
+ font = flatten_mtd.shift
117
+ font.new(
118
+ Utility.filter_values(flatten_mtd),
119
+ Utility::OMML_FONTS.invert[font].to_s,
120
+ )
121
+ else
122
+ flatten_mtd
123
+ end
124
+ end
125
+
110
126
  rule(mr: subtree(:mr)) do
111
127
  row = []
112
128
  mr.each do |td|
113
- row << Math::Function::Td.new(
114
- Array(td),
115
- )
129
+ row << Math::Function::Td.new(Array(td))
116
130
  end
117
131
  Math::Function::Tr.new(row)
118
132
  end
@@ -562,8 +562,8 @@ module Plurimath
562
562
  close_paren = mrow.pop
563
563
  if mrow.length == 1 && mrow.first.is_a?(Math::Function::Table)
564
564
  table = mrow.first
565
- table.open_paren = open_paren
566
- table.close_paren = close_paren
565
+ table.open_paren = open_paren.value
566
+ table.close_paren = close_paren.value
567
567
  else
568
568
  mrow.replace(
569
569
  [
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Plurimath
4
- VERSION = "0.4.3"
4
+ VERSION = "0.4.4"
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.4.3
4
+ version: 0.4.4
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-08-30 00:00:00.000000000 Z
11
+ date: 2023-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parslet