mathtype_to_mathml 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +14 -0
  3. data/.rspec +2 -0
  4. data/.ruby-version +1 -0
  5. data/.travis.yml +3 -0
  6. data/Gemfile +6 -0
  7. data/LICENSE.txt +22 -0
  8. data/README.md +45 -0
  9. data/Rakefile +7 -0
  10. data/lib/mathtype_to_mathml.rb +28 -0
  11. data/lib/mathtype_to_mathml/char_replacer.rb +311 -0
  12. data/lib/mathtype_to_mathml/mover.rb +151 -0
  13. data/lib/mathtype_to_mathml/version.rb +3 -0
  14. data/lib/transform.xsl +104 -0
  15. data/lib/xsl/arrow.xsl +319 -0
  16. data/lib/xsl/brace.xsl +55 -0
  17. data/lib/xsl/char.xsl +35 -0
  18. data/lib/xsl/embellishment.xsl +389 -0
  19. data/lib/xsl/matrix.xsl +116 -0
  20. data/lib/xsl/pile.xsl +54 -0
  21. data/lib/xsl/subsup.xsl +55 -0
  22. data/lib/xsl/sum.xsl +57 -0
  23. data/lib/xsl/union_intersection.xsl +104 -0
  24. data/mathtype_to_mathml.gemspec +28 -0
  25. data/spec/fixtures/expected/arrows.xml +389 -0
  26. data/spec/fixtures/expected/embellishments.xml +178 -0
  27. data/spec/fixtures/expected/equation1.xml +52 -0
  28. data/spec/fixtures/expected/equation10.xml +19 -0
  29. data/spec/fixtures/expected/equation11.xml +17 -0
  30. data/spec/fixtures/expected/equation12.xml +34 -0
  31. data/spec/fixtures/expected/equation13.xml +113 -0
  32. data/spec/fixtures/expected/equation2.xml +33 -0
  33. data/spec/fixtures/expected/equation3.xml +324 -0
  34. data/spec/fixtures/expected/equation4.xml +14 -0
  35. data/spec/fixtures/expected/equation5.xml +23 -0
  36. data/spec/fixtures/expected/equation6.xml +13 -0
  37. data/spec/fixtures/expected/equation7.xml +19 -0
  38. data/spec/fixtures/expected/equation8.xml +17 -0
  39. data/spec/fixtures/expected/equation9.xml +15 -0
  40. data/spec/fixtures/input/arrows.bin +0 -0
  41. data/spec/fixtures/input/embellishments.bin +0 -0
  42. data/spec/fixtures/input/equation1.bin +0 -0
  43. data/spec/fixtures/input/equation10.bin +0 -0
  44. data/spec/fixtures/input/equation11.bin +0 -0
  45. data/spec/fixtures/input/equation12.bin +0 -0
  46. data/spec/fixtures/input/equation13.bin +0 -0
  47. data/spec/fixtures/input/equation2.bin +0 -0
  48. data/spec/fixtures/input/equation3.bin +0 -0
  49. data/spec/fixtures/input/equation4.bin +0 -0
  50. data/spec/fixtures/input/equation5.bin +0 -0
  51. data/spec/fixtures/input/equation6.bin +0 -0
  52. data/spec/fixtures/input/equation7.bin +0 -0
  53. data/spec/fixtures/input/equation8.bin +0 -0
  54. data/spec/fixtures/input/equation9.bin +0 -0
  55. data/spec/html_output.rb +28 -0
  56. data/spec/mathtype_to_mathml_spec.rb +19 -0
  57. data/spec/spec_helper.rb +2 -0
  58. metadata +220 -0
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,28 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require "mathtype_to_mathml"
3
+ require "nokogiri"
4
+
5
+ builder = Nokogiri::HTML::Builder.new do |html|
6
+ html.html do
7
+ html.body do
8
+ Dir.glob("spec/fixtures/input/*.bin") do |equation|
9
+ html.div do |div|
10
+ div.h3 equation
11
+ div.p "Output", "style" => "text-align: center;"
12
+ div.p do |p|
13
+ p << MathTypeToMathML::Converter.new(equation).convert
14
+ end
15
+ expected_xml = "#{File.basename(equation, ".*")}.xml"
16
+ expected = File.open("spec/fixtures/expected/" + expected_xml).read
17
+ div.p "Expected", "style" => "text-align: center;"
18
+ div.p do |p|
19
+ p << expected
20
+ end
21
+ div.hr
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+ puts builder.to_html
@@ -0,0 +1,19 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe MathTypeToMathML do
4
+ it 'has a version number' do
5
+ expect(MathTypeToMathML::VERSION).not_to be nil
6
+ end
7
+
8
+ Dir.glob("spec/fixtures/input/*.bin") do |equation|
9
+ it "converted #{equation} matches expected output" do
10
+ xml = MathTypeToMathML::Converter.new(equation).convert
11
+ expected_xml = "#{File.basename(equation, ".*")}.xml"
12
+ File.open("spec/fixtures/expected/" + expected_xml, "w+") do |file|
13
+ file.write xml
14
+ end
15
+ expected = File.open("spec/fixtures/expected/" + expected_xml).read
16
+ expect(xml).to eq(expected)
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require "mathtype_to_mathml"
metadata ADDED
@@ -0,0 +1,220 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mathtype_to_mathml
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - PLOS
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-08-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.10'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.10'
69
+ - !ruby/object:Gem::Dependency
70
+ name: nokogiri
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.6'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.6'
83
+ - !ruby/object:Gem::Dependency
84
+ name: mathtype
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.0.5
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.0.5
97
+ description: This gem can be used to convert MathType equations from a binary format
98
+ (e.g. embedded in Word documents) to an open MathML representation. It achieves
99
+ that in several stages, first using the "mathtype" gem to convert from a binary
100
+ to an XML form of MTEF, and second, using XSLTs to convert XML to MathML.
101
+ email:
102
+ - plos@plos.org
103
+ executables: []
104
+ extensions: []
105
+ extra_rdoc_files: []
106
+ files:
107
+ - ".gitignore"
108
+ - ".rspec"
109
+ - ".ruby-version"
110
+ - ".travis.yml"
111
+ - Gemfile
112
+ - LICENSE.txt
113
+ - README.md
114
+ - Rakefile
115
+ - lib/mathtype_to_mathml.rb
116
+ - lib/mathtype_to_mathml/char_replacer.rb
117
+ - lib/mathtype_to_mathml/mover.rb
118
+ - lib/mathtype_to_mathml/version.rb
119
+ - lib/transform.xsl
120
+ - lib/xsl/arrow.xsl
121
+ - lib/xsl/brace.xsl
122
+ - lib/xsl/char.xsl
123
+ - lib/xsl/embellishment.xsl
124
+ - lib/xsl/matrix.xsl
125
+ - lib/xsl/pile.xsl
126
+ - lib/xsl/subsup.xsl
127
+ - lib/xsl/sum.xsl
128
+ - lib/xsl/union_intersection.xsl
129
+ - mathtype_to_mathml.gemspec
130
+ - spec/fixtures/expected/arrows.xml
131
+ - spec/fixtures/expected/embellishments.xml
132
+ - spec/fixtures/expected/equation1.xml
133
+ - spec/fixtures/expected/equation10.xml
134
+ - spec/fixtures/expected/equation11.xml
135
+ - spec/fixtures/expected/equation12.xml
136
+ - spec/fixtures/expected/equation13.xml
137
+ - spec/fixtures/expected/equation2.xml
138
+ - spec/fixtures/expected/equation3.xml
139
+ - spec/fixtures/expected/equation4.xml
140
+ - spec/fixtures/expected/equation5.xml
141
+ - spec/fixtures/expected/equation6.xml
142
+ - spec/fixtures/expected/equation7.xml
143
+ - spec/fixtures/expected/equation8.xml
144
+ - spec/fixtures/expected/equation9.xml
145
+ - spec/fixtures/input/arrows.bin
146
+ - spec/fixtures/input/embellishments.bin
147
+ - spec/fixtures/input/equation1.bin
148
+ - spec/fixtures/input/equation10.bin
149
+ - spec/fixtures/input/equation11.bin
150
+ - spec/fixtures/input/equation12.bin
151
+ - spec/fixtures/input/equation13.bin
152
+ - spec/fixtures/input/equation2.bin
153
+ - spec/fixtures/input/equation3.bin
154
+ - spec/fixtures/input/equation4.bin
155
+ - spec/fixtures/input/equation5.bin
156
+ - spec/fixtures/input/equation6.bin
157
+ - spec/fixtures/input/equation7.bin
158
+ - spec/fixtures/input/equation8.bin
159
+ - spec/fixtures/input/equation9.bin
160
+ - spec/html_output.rb
161
+ - spec/mathtype_to_mathml_spec.rb
162
+ - spec/spec_helper.rb
163
+ homepage: ''
164
+ licenses:
165
+ - MIT
166
+ metadata: {}
167
+ post_install_message:
168
+ rdoc_options: []
169
+ require_paths:
170
+ - lib
171
+ required_ruby_version: !ruby/object:Gem::Requirement
172
+ requirements:
173
+ - - ">="
174
+ - !ruby/object:Gem::Version
175
+ version: '0'
176
+ required_rubygems_version: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ requirements: []
182
+ rubyforge_project:
183
+ rubygems_version: 2.4.5
184
+ signing_key:
185
+ specification_version: 4
186
+ summary: Converts from a binary MathType format (MTEF) to MathML.
187
+ test_files:
188
+ - spec/fixtures/expected/arrows.xml
189
+ - spec/fixtures/expected/embellishments.xml
190
+ - spec/fixtures/expected/equation1.xml
191
+ - spec/fixtures/expected/equation10.xml
192
+ - spec/fixtures/expected/equation11.xml
193
+ - spec/fixtures/expected/equation12.xml
194
+ - spec/fixtures/expected/equation13.xml
195
+ - spec/fixtures/expected/equation2.xml
196
+ - spec/fixtures/expected/equation3.xml
197
+ - spec/fixtures/expected/equation4.xml
198
+ - spec/fixtures/expected/equation5.xml
199
+ - spec/fixtures/expected/equation6.xml
200
+ - spec/fixtures/expected/equation7.xml
201
+ - spec/fixtures/expected/equation8.xml
202
+ - spec/fixtures/expected/equation9.xml
203
+ - spec/fixtures/input/arrows.bin
204
+ - spec/fixtures/input/embellishments.bin
205
+ - spec/fixtures/input/equation1.bin
206
+ - spec/fixtures/input/equation10.bin
207
+ - spec/fixtures/input/equation11.bin
208
+ - spec/fixtures/input/equation12.bin
209
+ - spec/fixtures/input/equation13.bin
210
+ - spec/fixtures/input/equation2.bin
211
+ - spec/fixtures/input/equation3.bin
212
+ - spec/fixtures/input/equation4.bin
213
+ - spec/fixtures/input/equation5.bin
214
+ - spec/fixtures/input/equation6.bin
215
+ - spec/fixtures/input/equation7.bin
216
+ - spec/fixtures/input/equation8.bin
217
+ - spec/fixtures/input/equation9.bin
218
+ - spec/html_output.rb
219
+ - spec/mathtype_to_mathml_spec.rb
220
+ - spec/spec_helper.rb