plurimath 0.3.2 → 0.3.3

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: 8c90b0eb8f6510c5a93742653d0a9d395de3adf3b7dfa53f43d53ce4d7821a27
4
- data.tar.gz: 966c4a94fc1245cec98e7290e3761be0774a71d62403e38bfa405aa1db5cd9f8
3
+ metadata.gz: dc53f153a22d8b615db765dda8d7b22c72d8cf42ee522a678649d52b3eed66b6
4
+ data.tar.gz: d31664e4104fe46e1361adc6b4e1a38d189590d181cf04e668c6d5d8f3a5f1d5
5
5
  SHA512:
6
- metadata.gz: 364d72c3e42db84c13b5896ec36ea4cdb5f856ebdd970e7ff1058f3c2251cb301dd641cb51e1addcb5c890cfbd83cdebc5cf91df48e495704a8eae355b502d82
7
- data.tar.gz: 607a1cf277fcbdce40ab130397985e8bf5682662adb747debb42823b257201e110d9aa4d7cb1087a191e98efeadab5976e723c2a9a6f64deb4e38bdf8fa513a1
6
+ metadata.gz: 6e8b0ececc1885c1751a0a9753a548f775c4cf740173c423dddbcf76dbfec8bb42db60773f744344402ea83e46e2c6bd99d43f85c54a12386383f0d83448f535
7
+ data.tar.gz: 4313751a9dde187e15adfbf6faa8f0c6fe015a753e286c84c2ea5cb7d5dd57c81c3e2c2e8bdaacffd1db58ff90f08fe82c5803983fe6a4027c9aade374190e8a
@@ -70,7 +70,7 @@ module Plurimath
70
70
  quoted_text |
71
71
  (str("d").as(:d) >> str("x").as(:x)).as(:intermediate_exp) |
72
72
  match["a-zA-Z"].as(:symbol) |
73
- match(/[^\[{(\\\/@;:.,'"|\]})0-9a-zA-Z\-><$%^&*_=+!`~\s?]/).as(:symbol) |
73
+ match(/[^\[{(\\\/@;:.,'"|\]})0-9a-zA-Z\-><$%^&*_=+!`~\s?ℒℛ]/).as(:symbol) |
74
74
  number
75
75
  end
76
76
 
@@ -127,12 +127,6 @@ module Plurimath
127
127
  new_arr
128
128
  end
129
129
 
130
- rule(sequence: simple(:sequence),
131
- left_right: sequence(:left_right)) do
132
- left_right.insert(0, sequence)
133
- left_right
134
- end
135
-
136
130
  rule(table_row: simple(:table_row),
137
131
  expr: simple(:expr)) do
138
132
  new_arr = [table_row]
@@ -157,6 +151,11 @@ module Plurimath
157
151
  expr.flatten.compact.insert(0, Utility.symbol_object(comma))
158
152
  end
159
153
 
154
+ rule(symbol: simple(:symbol),
155
+ expr: sequence(:expr)) do
156
+ expr.flatten.compact.insert(0, Utility.symbol_object(symbol))
157
+ end
158
+
160
159
  rule(rparen: simple(:rparen),
161
160
  expr: simple(:expr)) do
162
161
  [
@@ -316,19 +315,6 @@ module Plurimath
316
315
  )
317
316
  end
318
317
 
319
- rule(fonts_class: simple(:font_style),
320
- fonts_value: simple(:fonts_value),
321
- power: simple(:power)) do
322
- font_object = Utility::FONT_STYLES[font_style.to_sym].new(
323
- Utility.unfenced_value(fonts_value),
324
- font_style.to_s,
325
- )
326
- Math::Function::Power.new(
327
- font_object,
328
- Utility.unfenced_value(power),
329
- )
330
- end
331
-
332
318
  rule(unary_class: simple(:function),
333
319
  fonts_class: simple(:font_style),
334
320
  fonts_value: simple(:fonts_value)) do
@@ -344,24 +330,18 @@ module Plurimath
344
330
  Utility.get_class(function).new(first_value)
345
331
  end
346
332
 
347
- rule(fonts_class: simple(:font_style),
348
- fonts_value: simple(:fonts_value),
349
- base: simple(:base)) do
350
- font_object = Utility::FONT_STYLES[font_style.to_sym].new(
351
- Utility.unfenced_value(fonts_value),
352
- font_style.to_s,
353
- )
354
- Math::Function::Base.new(
355
- font_object,
356
- Utility.unfenced_value(base),
357
- )
358
- end
359
-
360
333
  rule(power_base: simple(:power_base),
361
334
  expr: subtree(:expr)) do
362
335
  expr.flatten.compact.insert(0, power_base)
363
336
  end
364
337
 
338
+ rule(power_base: simple(:power_base),
339
+ expr: simple(:expr)) do
340
+ new_arr = [power_base]
341
+ new_arr << expr unless expr.to_s.strip.empty?
342
+ new_arr
343
+ end
344
+
365
345
  rule(frac: simple(:frac),
366
346
  expr: subtree(:expr)) do
367
347
  case expr
@@ -386,29 +366,6 @@ module Plurimath
386
366
  new_arr
387
367
  end
388
368
 
389
- rule(sequence: simple(:sequence),
390
- frac: simple(:frac)) do
391
- new_arr = [sequence]
392
- new_arr << frac unless frac.to_s.strip.empty?
393
- new_arr
394
- end
395
-
396
- rule(sequence: simple(:sequence),
397
- base: simple(:base)) do
398
- Math::Function::Base.new(
399
- sequence,
400
- Utility.unfenced_value(base),
401
- )
402
- end
403
-
404
- rule(power_base: simple(:power_base),
405
- power: simple(:power)) do
406
- Math::Function::Power.new(
407
- power_base,
408
- Utility.unfenced_value(power),
409
- )
410
- end
411
-
412
369
  rule(power_base: simple(:power_base),
413
370
  power: sequence(:power)) do
414
371
  first_value = power.shift if Utility.frac_values(power)
@@ -420,16 +377,6 @@ module Plurimath
420
377
  end
421
378
  end
422
379
 
423
- rule(sequence: simple(:sequence),
424
- symbol: simple(:symbol)) do
425
- symbol_object = Utility.symbol_object(
426
- (Constants::SYMBOLS[symbol.to_sym] || symbol).to_s,
427
- )
428
- new_arr = [sequence]
429
- new_arr << symbol_object unless symbol.to_s.strip.empty?
430
- new_arr
431
- end
432
-
433
380
  rule(power_base: simple(:power_base),
434
381
  left_right: simple(:left_right)) do
435
382
  new_arr = [power_base]
@@ -459,10 +406,25 @@ module Plurimath
459
406
 
460
407
  rule(power_base: simple(:power_base),
461
408
  base: simple(:base)) do
462
- Math::Function::Base.new(
463
- power_base,
464
- Utility.unfenced_value(base),
465
- )
409
+ if base.is_a?(Math::Formula) && base.value.any? { |value| Utility.symbol_value(value, ",") }
410
+ sliced = base.value.slice_before { |object| Utility.symbol_value(object, ",") }.to_a
411
+ base_object = Math::Function::Base.new(
412
+ power_base,
413
+ Utility.filter_values(
414
+ Utility.unfenced_value(sliced.shift),
415
+ ),
416
+ )
417
+ [
418
+ base_object,
419
+ sliced.shift.first,
420
+ Utility.filter_values(sliced),
421
+ ].compact
422
+ else
423
+ Math::Function::Base.new(
424
+ power_base,
425
+ Utility.unfenced_value(base),
426
+ )
427
+ end
466
428
  end
467
429
 
468
430
  rule(power_base: simple(:power_base),
@@ -510,16 +472,7 @@ module Plurimath
510
472
  Utility.unfenced_value(base_value),
511
473
  Utility.filter_values(first_value),
512
474
  )
513
- if power_value.empty?
514
- power_base_object
515
- else
516
- Math::Formula.new(
517
- power_value.insert(
518
- 0,
519
- power_base_object,
520
- ),
521
- )
522
- end
475
+ power_value.insert(0, power_base_object)
523
476
  end
524
477
 
525
478
  rule(power_base: simple(:power_base),
@@ -630,37 +583,6 @@ module Plurimath
630
583
  new_arr
631
584
  end
632
585
 
633
- rule(intermediate_exp: simple(:int_exp),
634
- power: simple(:power)) do
635
- Math::Function::Power.new(
636
- int_exp,
637
- Utility.unfenced_value(power),
638
- )
639
- end
640
-
641
- rule(intermediate_exp: simple(:int_exp),
642
- power: sequence(:power)) do
643
- Math::Function::Power.new(
644
- int_exp,
645
- Utility.unfenced_value(power),
646
- )
647
- end
648
-
649
- rule(intermediate_exp: simple(:int_exp),
650
- base: simple(:base)) do
651
- Math::Function::Base.new(
652
- int_exp,
653
- Utility.unfenced_value(base),
654
- )
655
- end
656
-
657
- rule(power_base: simple(:power_base),
658
- expr: simple(:expr)) do
659
- new_arr = [power_base]
660
- new_arr << expr unless expr.to_s.strip.empty?
661
- new_arr
662
- end
663
-
664
586
  rule(power_base: sequence(:power_base),
665
587
  expr: simple(:expr)) do
666
588
  new_arr = power_base
@@ -697,22 +619,6 @@ module Plurimath
697
619
  sequence.flatten.compact + expr.flatten.compact
698
620
  end
699
621
 
700
- rule(unary: simple(:unary),
701
- power: simple(:power)) do
702
- Math::Function::Power.new(
703
- unary,
704
- Utility.unfenced_value(power),
705
- )
706
- end
707
-
708
- rule(unary: simple(:unary),
709
- base: simple(:base)) do
710
- Math::Function::Base.new(
711
- unary,
712
- Utility.unfenced_value(base),
713
- )
714
- end
715
-
716
622
  rule(binary_class: simple(:function),
717
623
  base_value: simple(:base)) do
718
624
  Utility.get_class(function).new(
@@ -720,17 +626,6 @@ module Plurimath
720
626
  )
721
627
  end
722
628
 
723
- rule(binary_class: simple(:function),
724
- base_value: sequence(:base)) do
725
- binary = Utility.get_class(function).new(
726
- Utility.unfenced_value(base.shift),
727
- Utility.unfenced_value(base.shift),
728
- )
729
- new_arr = [binary]
730
- new_arr += base.flatten.compact unless base.empty?
731
- new_arr
732
- end
733
-
734
629
  rule(d: simple(:d),
735
630
  x: simple(:x)) do
736
631
  Math::Formula.new(
@@ -741,52 +636,6 @@ module Plurimath
741
636
  )
742
637
  end
743
638
 
744
- rule(symbol: simple(:symbol),
745
- power: simple(:power)) do
746
- Math::Function::Power.new(
747
- Utility.symbol_object(
748
- (Constants::SYMBOLS[symbol.to_sym] || symbol).to_s,
749
- ),
750
- Utility.unfenced_value(power),
751
- )
752
- end
753
-
754
- rule(symbol: simple(:symbol),
755
- power: sequence(:power)) do
756
- Math::Function::Power.new(
757
- Utility.symbol_object(
758
- (Constants::SYMBOLS[symbol.to_sym] || symbol).to_s,
759
- ),
760
- Utility.unfenced_value(power),
761
- )
762
- end
763
-
764
- rule(symbol: simple(:sym),
765
- expr: sequence(:expr)) do
766
- symbol = Utility.symbol_object(
767
- (Constants::SYMBOLS[sym.to_sym] || sym).to_s,
768
- )
769
- expr.flatten.compact.insert(0, symbol)
770
- end
771
-
772
- rule(symbol: simple(:sym),
773
- expr: simple(:expr)) do
774
- symbol = Utility.symbol_object(
775
- (Constants::SYMBOLS[sym.to_sym] || sym).to_s,
776
- )
777
- [symbol, expr]
778
- end
779
-
780
- rule(symbol: simple(:symbol),
781
- base: simple(:base)) do
782
- Math::Function::Base.new(
783
- Utility.symbol_object(
784
- (Constants::SYMBOLS[symbol.to_sym] || symbol).to_s,
785
- ),
786
- Utility.unfenced_value(base),
787
- )
788
- end
789
-
790
639
  rule(binary_class: simple(:function),
791
640
  base: simple(:base)) do
792
641
  Utility.get_class(function).new(
@@ -831,31 +680,6 @@ module Plurimath
831
680
  )
832
681
  end
833
682
 
834
- rule(binary_class: simple(:function),
835
- base_value: simple(:base),
836
- power_value: simple(:power),
837
- expr: sequence(:expr)) do
838
- [
839
- Utility.get_class(function).new(
840
- Utility.unfenced_value(base),
841
- Utility.unfenced_value(power),
842
- ),
843
- ] + expr
844
- end
845
-
846
- rule(binary_class: simple(:function),
847
- base_value: simple(:base),
848
- power_value: simple(:power),
849
- expr: simple(:expr)) do
850
- [
851
- Utility.get_class(function).new(
852
- Utility.unfenced_value(base),
853
- Utility.unfenced_value(power),
854
- ),
855
- expr,
856
- ]
857
- end
858
-
859
683
  rule(unary_class: simple(:function),
860
684
  intermediate_exp: simple(:int_exp)) do
861
685
  first_value = if Utility::UNARY_CLASSES.include?(function)
@@ -913,54 +737,6 @@ module Plurimath
913
737
  ]
914
738
  end
915
739
 
916
- rule(number: simple(:number),
917
- power: simple(:power)) do
918
- Math::Function::Power.new(
919
- Math::Number.new(number),
920
- Utility.unfenced_value(power),
921
- )
922
- end
923
-
924
- rule(number: simple(:number),
925
- power: sequence(:power)) do
926
- Math::Function::Power.new(
927
- Math::Number.new(number),
928
- Utility.unfenced_value(power),
929
- )
930
- end
931
-
932
- rule(text: simple(:text),
933
- base: simple(:base)) do
934
- Math::Function::Base.new(
935
- Math::Function::Text.new(text),
936
- Utility.unfenced_value(base),
937
- )
938
- end
939
-
940
- rule(text: sequence(:text),
941
- base: simple(:base)) do
942
- Math::Function::Base.new(
943
- Math::Function::Text.new(text.join),
944
- Utility.unfenced_value(base),
945
- )
946
- end
947
-
948
- rule(text: simple(:text),
949
- power: simple(:power)) do
950
- Math::Function::Power.new(
951
- Math::Function::Text.new(text),
952
- Utility.unfenced_value(power),
953
- )
954
- end
955
-
956
- rule(text: sequence(:text),
957
- power: simple(:power)) do
958
- Math::Function::Power.new(
959
- Math::Function::Text.new(text.join),
960
- Utility.unfenced_value(power),
961
- )
962
- end
963
-
964
740
  rule(table: simple(:table),
965
741
  expr: sequence(:expr)) do
966
742
  Math::Formula.new([table] + expr.flatten.compact)
@@ -994,92 +770,6 @@ module Plurimath
994
770
  )
995
771
  end
996
772
 
997
- rule(text: simple(:text),
998
- base_value: simple(:base),
999
- power_value: simple(:power)) do
1000
- Math::Function::PowerBase.new(
1001
- Math::Function::Text.new(text),
1002
- Utility.unfenced_value(base),
1003
- Utility.unfenced_value(power),
1004
- )
1005
- end
1006
-
1007
- rule(number: simple(:number),
1008
- base_value: simple(:base),
1009
- power_value: simple(:power)) do
1010
- Math::Function::PowerBase.new(
1011
- Math::Number.new(number),
1012
- Utility.unfenced_value(base),
1013
- Utility.unfenced_value(power),
1014
- )
1015
- end
1016
-
1017
- rule(unary: simple(:unary),
1018
- base_value: simple(:base),
1019
- power_value: simple(:power)) do
1020
- Math::Function::PowerBase.new(
1021
- unary,
1022
- Utility.unfenced_value(base),
1023
- Utility.unfenced_value(power),
1024
- )
1025
- end
1026
-
1027
- rule(unary: sequence(:unary),
1028
- base_value: simple(:base),
1029
- power_value: simple(:power)) do
1030
- unary.first.new(
1031
- unary.last.new(
1032
- Utility.unfenced_value(base),
1033
- Utility.unfenced_value(power),
1034
- ),
1035
- )
1036
- end
1037
-
1038
- rule(intermediate_exp: simple(:int_exp),
1039
- base_value: simple(:base),
1040
- power_value: simple(:power)) do
1041
- Math::Function::PowerBase.new(
1042
- int_exp,
1043
- Utility.unfenced_value(base),
1044
- Utility.unfenced_value(power),
1045
- )
1046
- end
1047
-
1048
- rule(intermediate_exp: simple(:int_exp),
1049
- base_value: simple(:base),
1050
- power_value: sequence(:power)) do
1051
- Math::Function::PowerBase.new(
1052
- int_exp,
1053
- Utility.unfenced_value(base),
1054
- Utility.filter_values(power),
1055
- )
1056
- end
1057
-
1058
- rule(symbol: simple(:symbol),
1059
- base_value: simple(:base),
1060
- power_value: simple(:power)) do
1061
- Math::Function::PowerBase.new(
1062
- Utility.symbol_object(
1063
- (Constants::SYMBOLS[symbol.to_sym] || symbol).to_s,
1064
- ),
1065
- Utility.unfenced_value(base),
1066
- Utility.unfenced_value(power),
1067
- )
1068
- end
1069
-
1070
- rule(symbol: simple(:symbol),
1071
- base_value: simple(:base),
1072
- power_value: sequence(:power)) do
1073
- symbol_object = Utility.symbol_object(
1074
- (Constants::SYMBOLS[symbol.to_sym] || symbol).to_s,
1075
- )
1076
- Math::Function::PowerBase.new(
1077
- symbol_object,
1078
- Utility.unfenced_value(base),
1079
- Utility.filter_values(power),
1080
- )
1081
- end
1082
-
1083
773
  rule(lparen: simple(:lparen),
1084
774
  expr: simple(:expr),
1085
775
  rparen: simple(:rparen)) do
@@ -1107,18 +797,6 @@ module Plurimath
1107
797
  )
1108
798
  end
1109
799
 
1110
- rule(lparen: simple(:lparen),
1111
- text: simple(:text),
1112
- rparen: simple(:rparen)) do
1113
- Math::Function::Text.new(text)
1114
- end
1115
-
1116
- rule(lparen: simple(:lparen),
1117
- text: sequence(:text),
1118
- rparen: simple(:rparen)) do
1119
- Math::Function::Text.new(text.flatten.compact.join)
1120
- end
1121
-
1122
800
  rule(lparen: simple(:lparen),
1123
801
  rgb_color: sequence(:color),
1124
802
  rparen: simple(:rparen)) do
@@ -310,8 +310,13 @@ module Plurimath
310
310
 
311
311
  rule(unary_functions: simple(:unary),
312
312
  supscript: simple(:supscript)) do
313
+ unary_function = if unary.is_a?(Parslet::Slice)
314
+ Utility.get_class(unary).new
315
+ else
316
+ unary
317
+ end
313
318
  Math::Function::Power.new(
314
- unary,
319
+ unary_function,
315
320
  supscript,
316
321
  )
317
322
  end
@@ -319,8 +324,13 @@ module Plurimath
319
324
  rule(unary_functions: simple(:unary),
320
325
  subscript: simple(:subscript),
321
326
  supscript: simple(:supscript)) do
327
+ unary_function = if unary.is_a?(Parslet::Slice)
328
+ Utility.get_class(unary).new
329
+ else
330
+ unary
331
+ end
322
332
  Math::Function::PowerBase.new(
323
- unary,
333
+ unary_function,
324
334
  subscript,
325
335
  supscript,
326
336
  )
@@ -554,14 +564,6 @@ module Plurimath
554
564
  )
555
565
  end
556
566
 
557
- rule(rparen: simple(:rparen),
558
- supscript: simple(:supscript)) do
559
- Math::Function::Power.new(
560
- Math::Symbol.new(rparen),
561
- supscript,
562
- )
563
- end
564
-
565
567
  rule(expression: simple(:expr),
566
568
  supscript: simple(:supscript)) do
567
569
  Math::Function::Power.new(
@@ -6,6 +6,18 @@ module Plurimath
6
6
  module Math
7
7
  module Function
8
8
  class Dot < UnaryFunction
9
+ def to_mathml_without_math_tag
10
+ first_value = parameter_one&.to_mathml_without_math_tag
11
+ dot_tag = (Utility.ox_element("mo") << ".")
12
+ over_tag = Utility.ox_element("mover")
13
+ Utility.update_nodes(
14
+ over_tag,
15
+ [
16
+ first_value,
17
+ dot_tag,
18
+ ],
19
+ )
20
+ end
9
21
  end
10
22
  end
11
23
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Plurimath
4
- VERSION = "0.3.2"
4
+ VERSION = "0.3.3"
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.3.2
4
+ version: 0.3.3
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-05-11 00:00:00.000000000 Z
11
+ date: 2023-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parslet