plurimath 0.2.0 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +13 -0
  3. data/.github/workflows/release.yml +22 -0
  4. data/.gitignore +1 -0
  5. data/.hound.yml +5 -0
  6. data/.rubocop.yml +8 -0
  7. data/AsciiMath-Supported-Data.adoc +2000 -0
  8. data/Gemfile +3 -0
  9. data/Latex-Supported-Data.adoc +1879 -0
  10. data/MathML-Supported-Data.adoc +287 -0
  11. data/README.adoc +96 -0
  12. data/lib/plurimath/asciimath/constants.rb +267 -229
  13. data/lib/plurimath/asciimath/parse.rb +125 -26
  14. data/lib/plurimath/asciimath/parser.rb +6 -3
  15. data/lib/plurimath/asciimath/transform.rb +1135 -208
  16. data/lib/plurimath/asciimath.rb +1 -1
  17. data/lib/plurimath/html/constants.rb +50 -0
  18. data/lib/plurimath/html/parse.rb +149 -0
  19. data/lib/plurimath/html/parser.rb +26 -0
  20. data/lib/plurimath/html/transform.rb +363 -0
  21. data/lib/plurimath/html.rb +1 -1
  22. data/lib/plurimath/latex/constants.rb +3729 -1906
  23. data/lib/plurimath/latex/parse.rb +167 -51
  24. data/lib/plurimath/latex/parser.rb +12 -4
  25. data/lib/plurimath/latex/transform.rb +598 -183
  26. data/lib/plurimath/math/base.rb +15 -0
  27. data/lib/plurimath/math/formula.rb +96 -11
  28. data/lib/plurimath/math/function/bar.rb +34 -0
  29. data/lib/plurimath/math/function/base.rb +32 -5
  30. data/lib/plurimath/math/function/binary_function.rb +104 -17
  31. data/lib/plurimath/math/function/cancel.rb +8 -0
  32. data/lib/plurimath/math/function/ceil.rb +3 -0
  33. data/lib/plurimath/math/function/color.rb +16 -6
  34. data/lib/plurimath/math/function/f.rb +8 -0
  35. data/lib/plurimath/math/function/fenced.rb +95 -3
  36. data/lib/plurimath/math/function/floor.rb +15 -0
  37. data/lib/plurimath/math/function/font_style/bold.rb +37 -0
  38. data/lib/plurimath/math/function/font_style/double_struck.rb +37 -0
  39. data/lib/plurimath/math/function/font_style/fraktur.rb +37 -0
  40. data/lib/plurimath/math/function/font_style/italic.rb +37 -0
  41. data/lib/plurimath/math/function/font_style/monospace.rb +37 -0
  42. data/lib/plurimath/math/function/font_style/normal.rb +37 -0
  43. data/lib/plurimath/math/function/font_style/sans-serif.rb +37 -0
  44. data/lib/plurimath/math/function/font_style/script.rb +37 -0
  45. data/lib/plurimath/math/function/font_style.rb +18 -25
  46. data/lib/plurimath/math/function/frac.rb +35 -5
  47. data/lib/plurimath/math/function/g.rb +7 -0
  48. data/lib/plurimath/math/function/hat.rb +12 -0
  49. data/lib/plurimath/math/function/inf.rb +21 -1
  50. data/lib/plurimath/math/function/int.rb +23 -2
  51. data/lib/plurimath/math/function/left.rb +25 -4
  52. data/lib/plurimath/math/function/lim.rb +40 -2
  53. data/lib/plurimath/math/function/limits.rb +8 -0
  54. data/lib/plurimath/math/function/log.rb +61 -4
  55. data/lib/plurimath/math/function/longdiv.rb +12 -0
  56. data/lib/plurimath/math/function/mbox.rb +31 -0
  57. data/lib/plurimath/math/function/menclose.rb +46 -0
  58. data/lib/plurimath/math/function/merror.rb +12 -0
  59. data/lib/plurimath/math/function/mod.rb +25 -4
  60. data/lib/plurimath/math/function/msgroup.rb +37 -0
  61. data/lib/plurimath/math/function/msline.rb +12 -0
  62. data/lib/plurimath/math/function/multiscript.rb +30 -0
  63. data/lib/plurimath/math/function/norm.rb +18 -1
  64. data/lib/plurimath/math/function/obrace.rb +17 -0
  65. data/lib/plurimath/math/function/oint.rb +2 -2
  66. data/lib/plurimath/math/function/over.rb +36 -0
  67. data/lib/plurimath/math/function/overset.rb +36 -7
  68. data/lib/plurimath/math/function/phantom.rb +28 -0
  69. data/lib/plurimath/math/function/power.rb +33 -9
  70. data/lib/plurimath/math/function/power_base.rb +110 -5
  71. data/lib/plurimath/math/function/prod.rb +29 -2
  72. data/lib/plurimath/math/function/right.rb +44 -0
  73. data/lib/plurimath/math/function/root.rb +27 -4
  74. data/lib/plurimath/math/function/rule.rb +33 -0
  75. data/lib/plurimath/math/function/scarries.rb +12 -0
  76. data/lib/plurimath/math/function/scarry.rb +12 -0
  77. data/lib/plurimath/math/function/sqrt.rb +24 -2
  78. data/lib/plurimath/math/function/stackrel.rb +27 -0
  79. data/lib/plurimath/math/function/substack.rb +7 -1
  80. data/lib/plurimath/math/function/sum.rb +56 -2
  81. data/lib/plurimath/math/function/sup.rb +3 -0
  82. data/lib/plurimath/math/function/table/align.rb +24 -0
  83. data/lib/plurimath/math/function/table/array.rb +44 -0
  84. data/lib/plurimath/math/function/table/bmatrix.rb +37 -0
  85. data/lib/plurimath/math/function/table/matrix.rb +32 -0
  86. data/lib/plurimath/math/function/table/multline.rb +24 -0
  87. data/lib/plurimath/math/function/table/pmatrix.rb +24 -0
  88. data/lib/plurimath/math/function/table/split.rb +24 -0
  89. data/lib/plurimath/math/function/table/vmatrix.rb +24 -0
  90. data/lib/plurimath/math/function/table.rb +190 -20
  91. data/lib/plurimath/math/function/td.rb +27 -9
  92. data/lib/plurimath/math/function/ternary_function.rb +83 -8
  93. data/lib/plurimath/math/function/text.rb +45 -8
  94. data/lib/plurimath/math/function/tr.rb +28 -4
  95. data/lib/plurimath/math/function/ubrace.rb +17 -0
  96. data/lib/plurimath/math/function/ul.rb +29 -0
  97. data/lib/plurimath/math/function/unary_function.rb +85 -7
  98. data/lib/plurimath/math/function/underline.rb +12 -0
  99. data/lib/plurimath/math/function/underover.rb +107 -0
  100. data/lib/plurimath/math/function/underset.rb +39 -0
  101. data/lib/plurimath/math/function/vec.rb +10 -0
  102. data/lib/plurimath/math/function.rb +13 -2
  103. data/lib/plurimath/math/number.rb +11 -3
  104. data/lib/plurimath/math/symbol.rb +57 -9
  105. data/lib/plurimath/math/unicode.rb +11 -0
  106. data/lib/plurimath/math.rb +15 -6
  107. data/lib/plurimath/mathml/constants.rb +224 -179
  108. data/lib/plurimath/mathml/parser.rb +24 -7
  109. data/lib/plurimath/mathml/transform.rb +249 -148
  110. data/lib/plurimath/mathml.rb +1 -1
  111. data/lib/plurimath/omml/parser.rb +42 -0
  112. data/lib/plurimath/omml/transform.rb +278 -0
  113. data/lib/plurimath/omml.rb +1 -1
  114. data/lib/plurimath/unitsml.rb +4 -0
  115. data/lib/plurimath/utility.rb +395 -0
  116. data/lib/plurimath/version.rb +1 -1
  117. data/plurimath.gemspec +1 -0
  118. metadata +66 -9
  119. data/.github/workflows/test.yml +0 -36
  120. data/README.md +0 -40
  121. data/lib/plurimath/mathml/parse.rb +0 -63
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.2
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: 2023-03-15 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
@@ -31,12 +45,17 @@ executables: []
31
45
  extensions: []
32
46
  extra_rdoc_files: []
33
47
  files:
34
- - ".github/workflows/test.yml"
48
+ - ".github/workflows/rake.yml"
49
+ - ".github/workflows/release.yml"
35
50
  - ".gitignore"
51
+ - ".hound.yml"
36
52
  - ".rubocop.yml"
53
+ - AsciiMath-Supported-Data.adoc
37
54
  - CODE_OF_CONDUCT.md
38
55
  - Gemfile
39
- - README.md
56
+ - Latex-Supported-Data.adoc
57
+ - MathML-Supported-Data.adoc
58
+ - README.adoc
40
59
  - Rakefile
41
60
  - bin/console
42
61
  - bin/setup
@@ -47,12 +66,17 @@ files:
47
66
  - lib/plurimath/asciimath/parser.rb
48
67
  - lib/plurimath/asciimath/transform.rb
49
68
  - lib/plurimath/html.rb
69
+ - lib/plurimath/html/constants.rb
70
+ - lib/plurimath/html/parse.rb
71
+ - lib/plurimath/html/parser.rb
72
+ - lib/plurimath/html/transform.rb
50
73
  - lib/plurimath/latex.rb
51
74
  - lib/plurimath/latex/constants.rb
52
75
  - lib/plurimath/latex/parse.rb
53
76
  - lib/plurimath/latex/parser.rb
54
77
  - lib/plurimath/latex/transform.rb
55
78
  - lib/plurimath/math.rb
79
+ - lib/plurimath/math/base.rb
56
80
  - lib/plurimath/math/formula.rb
57
81
  - lib/plurimath/math/function.rb
58
82
  - lib/plurimath/math/function/abs.rb
@@ -81,6 +105,14 @@ files:
81
105
  - lib/plurimath/math/function/fenced.rb
82
106
  - lib/plurimath/math/function/floor.rb
83
107
  - lib/plurimath/math/function/font_style.rb
108
+ - lib/plurimath/math/function/font_style/bold.rb
109
+ - lib/plurimath/math/function/font_style/double_struck.rb
110
+ - lib/plurimath/math/function/font_style/fraktur.rb
111
+ - lib/plurimath/math/function/font_style/italic.rb
112
+ - lib/plurimath/math/function/font_style/monospace.rb
113
+ - lib/plurimath/math/function/font_style/normal.rb
114
+ - lib/plurimath/math/function/font_style/sans-serif.rb
115
+ - lib/plurimath/math/function/font_style/script.rb
84
116
  - lib/plurimath/math/function/frac.rb
85
117
  - lib/plurimath/math/function/g.rb
86
118
  - lib/plurimath/math/function/gcd.rb
@@ -99,18 +131,31 @@ files:
99
131
  - lib/plurimath/math/function/limsup.rb
100
132
  - lib/plurimath/math/function/ln.rb
101
133
  - lib/plurimath/math/function/log.rb
134
+ - lib/plurimath/math/function/longdiv.rb
102
135
  - lib/plurimath/math/function/lub.rb
103
136
  - lib/plurimath/math/function/max.rb
137
+ - lib/plurimath/math/function/mbox.rb
138
+ - lib/plurimath/math/function/menclose.rb
139
+ - lib/plurimath/math/function/merror.rb
104
140
  - lib/plurimath/math/function/min.rb
105
141
  - lib/plurimath/math/function/mod.rb
142
+ - lib/plurimath/math/function/msgroup.rb
143
+ - lib/plurimath/math/function/msline.rb
144
+ - lib/plurimath/math/function/multiscript.rb
106
145
  - lib/plurimath/math/function/norm.rb
107
146
  - lib/plurimath/math/function/obrace.rb
108
147
  - lib/plurimath/math/function/oint.rb
148
+ - lib/plurimath/math/function/over.rb
109
149
  - lib/plurimath/math/function/overset.rb
150
+ - lib/plurimath/math/function/phantom.rb
110
151
  - lib/plurimath/math/function/power.rb
111
152
  - lib/plurimath/math/function/power_base.rb
112
153
  - lib/plurimath/math/function/prod.rb
154
+ - lib/plurimath/math/function/right.rb
113
155
  - lib/plurimath/math/function/root.rb
156
+ - lib/plurimath/math/function/rule.rb
157
+ - lib/plurimath/math/function/scarries.rb
158
+ - lib/plurimath/math/function/scarry.rb
114
159
  - lib/plurimath/math/function/sec.rb
115
160
  - lib/plurimath/math/function/sech.rb
116
161
  - lib/plurimath/math/function/sin.rb
@@ -121,6 +166,14 @@ files:
121
166
  - lib/plurimath/math/function/sum.rb
122
167
  - lib/plurimath/math/function/sup.rb
123
168
  - lib/plurimath/math/function/table.rb
169
+ - lib/plurimath/math/function/table/align.rb
170
+ - lib/plurimath/math/function/table/array.rb
171
+ - lib/plurimath/math/function/table/bmatrix.rb
172
+ - lib/plurimath/math/function/table/matrix.rb
173
+ - lib/plurimath/math/function/table/multline.rb
174
+ - lib/plurimath/math/function/table/pmatrix.rb
175
+ - lib/plurimath/math/function/table/split.rb
176
+ - lib/plurimath/math/function/table/vmatrix.rb
124
177
  - lib/plurimath/math/function/tan.rb
125
178
  - lib/plurimath/math/function/tanh.rb
126
179
  - lib/plurimath/math/function/td.rb
@@ -131,19 +184,23 @@ files:
131
184
  - lib/plurimath/math/function/ubrace.rb
132
185
  - lib/plurimath/math/function/ul.rb
133
186
  - lib/plurimath/math/function/unary_function.rb
187
+ - lib/plurimath/math/function/underline.rb
134
188
  - lib/plurimath/math/function/underover.rb
135
189
  - lib/plurimath/math/function/underset.rb
136
190
  - lib/plurimath/math/function/vec.rb
137
191
  - lib/plurimath/math/number.rb
138
192
  - lib/plurimath/math/symbol.rb
193
+ - lib/plurimath/math/unicode.rb
139
194
  - lib/plurimath/mathml.rb
140
195
  - lib/plurimath/mathml/constants.rb
141
- - lib/plurimath/mathml/parse.rb
142
196
  - lib/plurimath/mathml/parser.rb
143
197
  - lib/plurimath/mathml/transform.rb
144
198
  - lib/plurimath/omml.rb
199
+ - lib/plurimath/omml/parser.rb
200
+ - lib/plurimath/omml/transform.rb
145
201
  - lib/plurimath/unicode.rb
146
202
  - lib/plurimath/unitsml.rb
203
+ - lib/plurimath/utility.rb
147
204
  - lib/plurimath/version.rb
148
205
  - plurimath.gemspec
149
206
  homepage: https://github.com/plurimath/plurimath
@@ -152,7 +209,7 @@ licenses:
152
209
  metadata:
153
210
  homepage_uri: https://github.com/plurimath/plurimath
154
211
  source_code_uri: https://github.com/plurimath/plurimath
155
- post_install_message:
212
+ post_install_message:
156
213
  rdoc_options: []
157
214
  require_paths:
158
215
  - lib
@@ -167,8 +224,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
224
  - !ruby/object:Gem::Version
168
225
  version: '0'
169
226
  requirements: []
170
- rubygems_version: 3.1.2
171
- signing_key:
227
+ rubygems_version: 3.3.26
228
+ signing_key:
172
229
  specification_version: 4
173
230
  summary: Converts LaTeX math into MathML.
174
231
  test_files: []
@@ -1,36 +0,0 @@
1
- name: test
2
-
3
- on:
4
- push:
5
- branches: [ master ]
6
- tags:
7
- - '*'
8
- pull_request:
9
- paths-ignore:
10
- - .github/workflows/macos.yml
11
- - .github/workflows/windows.yml
12
-
13
- jobs:
14
- test-linux:
15
- name: Test on Ruby ${{ matrix.ruby }} ${{ matrix.os }}
16
- runs-on: ${{ matrix.os }}
17
- continue-on-error: ${{ matrix.experimental }}
18
- strategy:
19
- fail-fast: false
20
- matrix:
21
- ruby: [ '2.6', '2.7', '3.0' ]
22
- os: [ 'macos-latest', 'ubuntu-latest', 'windows-latest']
23
- experimental: [false]
24
- steps:
25
- - uses: actions/checkout@master
26
- - name: Use Ruby
27
- uses: ruby/setup-ruby@v1
28
- with:
29
- ruby-version: ${{ matrix.ruby }}
30
- - name: Update gems
31
- run: |
32
- gem install bundler
33
- bundle install --jobs 4 --retry 3
34
- - name: Run specs
35
- run: |
36
- bundle exec rake
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).
@@ -1,63 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "parslet"
4
- module Plurimath
5
- class Mathml
6
- class Parse < Parslet::Parser
7
- rule(:parse_record) do
8
- array_to_expression(Constants::CLASSES).as(:class) |
9
- array_to_expression(Constants::UNICODE_SYMBOLS.keys).as(:symbol) |
10
- array_to_expression(Constants::SYMBOLS.keys).as(:symbol) |
11
- match["a-zA-Z"].repeat(1).as(:text) |
12
- match(/[0-9]/).repeat(1).as(:number) |
13
- str("")
14
- end
15
-
16
- rule(:tag) { (parse_tag(:open) >> iteration.as(:iteration) >> parse_tag(:close)).as(:tag) | parse_text_tag.as(:tag) }
17
-
18
- rule(:sequence) { (tag >> sequence.as(:sequence)) | tag }
19
-
20
- rule(:iteration) { (sequence >> iteration.as(:iteration)) | parse_record }
21
-
22
- rule(:expression) { parse_tag(:open) >> iteration.as(:iteration) >> parse_tag(:close) }
23
-
24
- root :expression
25
-
26
- def array_to_expression(array, name = nil)
27
- initial_type = array.first.class
28
- array.reduce do |expr, tag|
29
- expr = str_to_expression(expr, name) if expr.is_a?(initial_type)
30
- expr | str_to_expression(tag, name)
31
- end
32
- end
33
-
34
- def str_to_expression(string, name)
35
- return str(string) if name.nil?
36
-
37
- str(string).as(name)
38
- end
39
-
40
- def parse_tag(opts)
41
- tag = str("<")
42
- tag = tag >> str("/") if opts == :close
43
- tag = tag >> array_to_expression(Constants::TAGS, opts)
44
- tag = tag >> attributes.as(:attributes) if opts == :open
45
- tag >> str(">")
46
- end
47
-
48
- def attributes
49
- (match["a-zA-Z"].repeat.as(:name) >>
50
- str("=") >> quoted_string).repeat
51
- end
52
-
53
- def quoted_string
54
- (str('"') >> match("[^\"]").repeat.as(:value) >> str('"')) |
55
- (str("'") >> match("[^\']").repeat.as(:value) >> str("'"))
56
- end
57
-
58
- def parse_text_tag
59
- str("<mtext>") >> match("[^<]").repeat.as(:quoted_text) >> str("</mtext>")
60
- end
61
- end
62
- end
63
- end