plurimath 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +8 -11
  3. data/.gitignore +1 -0
  4. data/AsciiMath-Supported-Data.adoc +280 -0
  5. data/Gemfile +1 -0
  6. data/Latex-Supported-Data.adoc +1872 -0
  7. data/MathML-Supported-Data.adoc +270 -0
  8. data/README.adoc +94 -0
  9. data/lib/plurimath/asciimath/constants.rb +215 -222
  10. data/lib/plurimath/asciimath/parse.rb +45 -11
  11. data/lib/plurimath/asciimath/parser.rb +4 -3
  12. data/lib/plurimath/asciimath/transform.rb +222 -131
  13. data/lib/plurimath/asciimath.rb +1 -1
  14. data/lib/plurimath/html/constants.rb +50 -0
  15. data/lib/plurimath/html/parse.rb +149 -0
  16. data/lib/plurimath/html/parser.rb +26 -0
  17. data/lib/plurimath/html/transform.rb +363 -0
  18. data/lib/plurimath/html.rb +1 -1
  19. data/lib/plurimath/latex/constants.rb +1885 -1858
  20. data/lib/plurimath/latex/parse.rb +127 -34
  21. data/lib/plurimath/latex/parser.rb +5 -4
  22. data/lib/plurimath/latex/transform.rb +324 -164
  23. data/lib/plurimath/math/formula.rb +9 -1
  24. data/lib/plurimath/math/function/bar.rb +1 -1
  25. data/lib/plurimath/math/function/base.rb +7 -1
  26. data/lib/plurimath/math/function/binary_function.rb +10 -5
  27. data/lib/plurimath/math/function/color.rb +4 -4
  28. data/lib/plurimath/math/function/fenced.rb +7 -2
  29. data/lib/plurimath/math/function/font_style/bold.rb +18 -0
  30. data/lib/plurimath/math/function/font_style/double_struck.rb +18 -0
  31. data/lib/plurimath/math/function/font_style/fraktur.rb +18 -0
  32. data/lib/plurimath/math/function/font_style/monospace.rb +18 -0
  33. data/lib/plurimath/math/function/font_style/sans-serif.rb +18 -0
  34. data/lib/plurimath/math/function/font_style/script.rb +18 -0
  35. data/lib/plurimath/math/function/font_style.rb +2 -22
  36. data/lib/plurimath/math/function/frac.rb +4 -4
  37. data/lib/plurimath/math/function/inf.rb +0 -1
  38. data/lib/plurimath/math/function/left.rb +3 -6
  39. data/lib/plurimath/math/function/limits.rb +0 -1
  40. data/lib/plurimath/math/function/log.rb +6 -0
  41. data/lib/plurimath/math/function/mod.rb +6 -0
  42. data/lib/plurimath/math/function/multiscript.rb +11 -0
  43. data/lib/plurimath/math/function/norm.rb +2 -1
  44. data/lib/plurimath/math/function/over.rb +29 -0
  45. data/lib/plurimath/math/function/overset.rb +2 -2
  46. data/lib/plurimath/math/function/power.rb +7 -1
  47. data/lib/plurimath/math/function/power_base.rb +14 -7
  48. data/lib/plurimath/math/function/prod.rb +6 -0
  49. data/lib/plurimath/math/function/right.rb +24 -0
  50. data/lib/plurimath/math/function/root.rb +5 -4
  51. data/lib/plurimath/math/function/sqrt.rb +1 -1
  52. data/lib/plurimath/math/function/substack.rb +0 -1
  53. data/lib/plurimath/math/function/sum.rb +6 -0
  54. data/lib/plurimath/math/function/table/align.rb +24 -0
  55. data/lib/plurimath/math/function/table/array.rb +25 -0
  56. data/lib/plurimath/math/function/table/bmatrix.rb +26 -0
  57. data/lib/plurimath/math/function/table/matrix.rb +24 -0
  58. data/lib/plurimath/math/function/table/multline.rb +24 -0
  59. data/lib/plurimath/math/function/table/pmatrix.rb +24 -0
  60. data/lib/plurimath/math/function/table/split.rb +24 -0
  61. data/lib/plurimath/math/function/table/vmatrix.rb +25 -0
  62. data/lib/plurimath/math/function/table.rb +17 -5
  63. data/lib/plurimath/math/function/td.rb +6 -1
  64. data/lib/plurimath/math/function/ternary_function.rb +16 -6
  65. data/lib/plurimath/math/function/text.rb +19 -7
  66. data/lib/plurimath/math/function/tr.rb +6 -1
  67. data/lib/plurimath/math/function/unary_function.rb +5 -0
  68. data/lib/plurimath/math/function/vec.rb +4 -0
  69. data/lib/plurimath/math/function.rb +13 -2
  70. data/lib/plurimath/math/number.rb +8 -0
  71. data/lib/plurimath/math/symbol.rb +12 -3
  72. data/lib/plurimath/math.rb +9 -4
  73. data/lib/plurimath/mathml/constants.rb +2 -34
  74. data/lib/plurimath/mathml/parse.rb +7 -2
  75. data/lib/plurimath/mathml/parser.rb +2 -1
  76. data/lib/plurimath/mathml/transform.rb +73 -68
  77. data/lib/plurimath/mathml.rb +1 -1
  78. data/lib/plurimath/omml/constants.rb +154 -0
  79. data/lib/plurimath/omml/parser.rb +22 -0
  80. data/lib/plurimath/omml/transform.rb +216 -0
  81. data/lib/plurimath/omml.rb +1 -1
  82. data/lib/plurimath/unitsml.rb +4 -0
  83. data/lib/plurimath/utility.rb +73 -0
  84. data/lib/plurimath/version.rb +1 -1
  85. data/plurimath.gemspec +1 -0
  86. metadata +49 -7
  87. data/README.md +0 -40
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Plurimath
4
+ class Utility
5
+ FONT_STYLES = {
6
+ "double-struck": Math::Function::FontStyle::DoubleStruck,
7
+ "sans-serif": Math::Function::FontStyle::SansSerif,
8
+ monospace: Math::Function::FontStyle::Monospace,
9
+ mathfrak: Math::Function::FontStyle::Fraktur,
10
+ mathcal: Math::Function::FontStyle::Script,
11
+ fraktur: Math::Function::FontStyle::Fraktur,
12
+ mathtt: Math::Function::FontStyle::Monospace,
13
+ mathbb: Math::Function::FontStyle::DoubleStruck,
14
+ script: Math::Function::FontStyle::Script,
15
+ mathsf: Math::Function::FontStyle::SansSerif,
16
+ mathbf: Math::Function::FontStyle::Bold,
17
+ bold: Math::Function::FontStyle::Bold,
18
+ bbb: Math::Function::FontStyle::DoubleStruck,
19
+ bf: Math::Function::FontStyle::Bold,
20
+ sf: Math::Function::FontStyle::SansSerif,
21
+ tt: Math::Function::FontStyle::Monospace,
22
+ fr: Math::Function::FontStyle::Fraktur,
23
+ cc: Math::Function::FontStyle::Script,
24
+ bb: Math::Function::FontStyle::Bold,
25
+ }.freeze
26
+
27
+ class << self
28
+ def organize_table(array, table = [], table_data = [], table_row = [])
29
+ table_separator = ["&", "\\\\"].freeze
30
+ array.each do |data|
31
+ if data.is_a?(Math::Symbol) && table_separator.include?(data.value)
32
+ table_row << Math::Function::Td.new(table_data)
33
+ table_data = []
34
+ if data.value == "\\\\"
35
+ table << Math::Function::Tr.new(table_row.flatten)
36
+ table_row = []
37
+ end
38
+ else
39
+ table_data << data
40
+ end
41
+ end
42
+ table_row << Math::Function::Td.new(table_data) if table_data
43
+ table << Math::Function::Tr.new(table_row) unless table_row.empty?
44
+ table
45
+ end
46
+
47
+ def get_table_class(text)
48
+ Object.const_get(
49
+ "Plurimath::Math::Function::Table::#{text.capitalize}",
50
+ )
51
+ end
52
+
53
+ def sub_sup_method?(sub_sup)
54
+ if sub_sup.methods.include?(:class_name)
55
+ Html::Constants::SUB_SUP_CLASSES.value?(sub_sup.class_name.to_sym)
56
+ end
57
+ end
58
+
59
+ def get_class(text)
60
+ Object.const_get(
61
+ "Plurimath::Math::Function::#{text.capitalize}",
62
+ )
63
+ end
64
+
65
+ def raise_error!(open_tag, close_tag)
66
+ message = "Please check your input."\
67
+ " Opening tag is \"#{open_tag}\""\
68
+ " and closing tag is \"#{close_tag}\""
69
+ raise Math::Error.new(message)
70
+ end
71
+ end
72
+ end
73
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Plurimath
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.1"
5
5
  end
data/plurimath.gemspec CHANGED
@@ -25,4 +25,5 @@ Gem::Specification.new do |spec|
25
25
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
26
  spec.require_paths = ["lib"]
27
27
  spec.add_dependency 'parslet'
28
+ spec.add_dependency 'ox'
28
29
  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.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-06 00:00:00.000000000 Z
11
+ date: 2022-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parslet
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: ox
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  description: Converts LaTeX math into MathML.
28
42
  email:
29
43
  - open.source@ribose.com
@@ -34,9 +48,12 @@ files:
34
48
  - ".github/workflows/test.yml"
35
49
  - ".gitignore"
36
50
  - ".rubocop.yml"
51
+ - AsciiMath-Supported-Data.adoc
37
52
  - CODE_OF_CONDUCT.md
38
53
  - Gemfile
39
- - README.md
54
+ - Latex-Supported-Data.adoc
55
+ - MathML-Supported-Data.adoc
56
+ - README.adoc
40
57
  - Rakefile
41
58
  - bin/console
42
59
  - bin/setup
@@ -47,6 +64,10 @@ files:
47
64
  - lib/plurimath/asciimath/parser.rb
48
65
  - lib/plurimath/asciimath/transform.rb
49
66
  - lib/plurimath/html.rb
67
+ - lib/plurimath/html/constants.rb
68
+ - lib/plurimath/html/parse.rb
69
+ - lib/plurimath/html/parser.rb
70
+ - lib/plurimath/html/transform.rb
50
71
  - lib/plurimath/latex.rb
51
72
  - lib/plurimath/latex/constants.rb
52
73
  - lib/plurimath/latex/parse.rb
@@ -81,6 +102,12 @@ files:
81
102
  - lib/plurimath/math/function/fenced.rb
82
103
  - lib/plurimath/math/function/floor.rb
83
104
  - lib/plurimath/math/function/font_style.rb
105
+ - lib/plurimath/math/function/font_style/bold.rb
106
+ - lib/plurimath/math/function/font_style/double_struck.rb
107
+ - lib/plurimath/math/function/font_style/fraktur.rb
108
+ - lib/plurimath/math/function/font_style/monospace.rb
109
+ - lib/plurimath/math/function/font_style/sans-serif.rb
110
+ - lib/plurimath/math/function/font_style/script.rb
84
111
  - lib/plurimath/math/function/frac.rb
85
112
  - lib/plurimath/math/function/g.rb
86
113
  - lib/plurimath/math/function/gcd.rb
@@ -103,13 +130,16 @@ files:
103
130
  - lib/plurimath/math/function/max.rb
104
131
  - lib/plurimath/math/function/min.rb
105
132
  - lib/plurimath/math/function/mod.rb
133
+ - lib/plurimath/math/function/multiscript.rb
106
134
  - lib/plurimath/math/function/norm.rb
107
135
  - lib/plurimath/math/function/obrace.rb
108
136
  - lib/plurimath/math/function/oint.rb
137
+ - lib/plurimath/math/function/over.rb
109
138
  - lib/plurimath/math/function/overset.rb
110
139
  - lib/plurimath/math/function/power.rb
111
140
  - lib/plurimath/math/function/power_base.rb
112
141
  - lib/plurimath/math/function/prod.rb
142
+ - lib/plurimath/math/function/right.rb
113
143
  - lib/plurimath/math/function/root.rb
114
144
  - lib/plurimath/math/function/sec.rb
115
145
  - lib/plurimath/math/function/sech.rb
@@ -121,6 +151,14 @@ files:
121
151
  - lib/plurimath/math/function/sum.rb
122
152
  - lib/plurimath/math/function/sup.rb
123
153
  - lib/plurimath/math/function/table.rb
154
+ - lib/plurimath/math/function/table/align.rb
155
+ - lib/plurimath/math/function/table/array.rb
156
+ - lib/plurimath/math/function/table/bmatrix.rb
157
+ - lib/plurimath/math/function/table/matrix.rb
158
+ - lib/plurimath/math/function/table/multline.rb
159
+ - lib/plurimath/math/function/table/pmatrix.rb
160
+ - lib/plurimath/math/function/table/split.rb
161
+ - lib/plurimath/math/function/table/vmatrix.rb
124
162
  - lib/plurimath/math/function/tan.rb
125
163
  - lib/plurimath/math/function/tanh.rb
126
164
  - lib/plurimath/math/function/td.rb
@@ -142,8 +180,12 @@ files:
142
180
  - lib/plurimath/mathml/parser.rb
143
181
  - lib/plurimath/mathml/transform.rb
144
182
  - lib/plurimath/omml.rb
183
+ - lib/plurimath/omml/constants.rb
184
+ - lib/plurimath/omml/parser.rb
185
+ - lib/plurimath/omml/transform.rb
145
186
  - lib/plurimath/unicode.rb
146
187
  - lib/plurimath/unitsml.rb
188
+ - lib/plurimath/utility.rb
147
189
  - lib/plurimath/version.rb
148
190
  - plurimath.gemspec
149
191
  homepage: https://github.com/plurimath/plurimath
@@ -152,7 +194,7 @@ licenses:
152
194
  metadata:
153
195
  homepage_uri: https://github.com/plurimath/plurimath
154
196
  source_code_uri: https://github.com/plurimath/plurimath
155
- post_install_message:
197
+ post_install_message:
156
198
  rdoc_options: []
157
199
  require_paths:
158
200
  - lib
@@ -167,8 +209,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
209
  - !ruby/object:Gem::Version
168
210
  version: '0'
169
211
  requirements: []
170
- rubygems_version: 3.1.2
171
- signing_key:
212
+ rubygems_version: 3.3.22
213
+ signing_key:
172
214
  specification_version: 4
173
215
  summary: Converts LaTeX math into MathML.
174
216
  test_files: []
data/README.md DELETED
@@ -1,40 +0,0 @@
1
- # Plurimath
2
-
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/plurimath`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
6
-
7
- ## Installation
8
-
9
- Add this line to your application's Gemfile:
10
-
11
- ```ruby
12
- gem 'plurimath'
13
- ```
14
-
15
- And then execute:
16
-
17
- $ bundle install
18
-
19
- Or install it yourself as:
20
-
21
- $ gem install plurimath
22
-
23
- ## Usage
24
-
25
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
-
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
-
33
- ## Contributing
34
-
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/plurimath. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/plurimath/blob/master/CODE_OF_CONDUCT.md).
36
-
37
-
38
- ## Code of Conduct
39
-
40
- Everyone interacting in the Plurimath project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/plurimath/blob/master/CODE_OF_CONDUCT.md).