mathematical 1.1.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/mathematical/extconf.rb +6 -1
- data/ext/mathematical/lasem/src/lsmdomcharacterdata.c +17 -0
- data/ext/mathematical/lasem/src/lsmdomdocument.c +17 -0
- data/ext/mathematical/lasem/src/lsmmathmlfencedelement.c +8 -6
- data/ext/mathematical/lasem/src/lsmmathmloperatorelement.c +8 -6
- data/ext/mathematical/lasem/src/lsmmathmlview.c +12 -7
- data/ext/mathematical/lasem/src/lsmmathmlview.h +2 -0
- data/ext/mathematical/lasem/src/lsmsvgsymbolelement.c +74 -0
- data/ext/mathematical/lasem/src/lsmsvgsymbolelement.h +3 -0
- data/ext/mathematical/lasem/src/lsmsvguseelement.c +10 -9
- data/ext/mathematical/lasem/src/lsmsvgview.c +12 -0
- data/ext/mathematical/lasem/src/lsmsvgview.h +1 -0
- data/ext/mathematical/lasem/tests/lsmtest.c +1 -1
- data/ext/mathematical/lasem/tests/suite.c +18 -1
- data/ext/mathematical/mtex2MML/src/lex.yy.c +4454 -4090
- data/ext/mathematical/mtex2MML/src/mtex2MML.h +1 -0
- data/ext/mathematical/mtex2MML/src/parse_extras.c +176 -41
- data/ext/mathematical/mtex2MML/src/parse_extras.h +30 -8
- data/ext/mathematical/mtex2MML/src/string_extras.c +5 -26
- data/ext/mathematical/mtex2MML/src/string_extras.h +1 -6
- data/ext/mathematical/mtex2MML/src/y.tab.c +6600 -5492
- data/ext/mathematical/mtex2MML/src/y.tab.h +572 -525
- data/lib/mathematical/version.rb +1 -1
- data/mathematical.gemspec +1 -1
- data/test/mathematical/basic_test.rb +1 -1
- data/test/mathematical/corrections_test.rb +1 -1
- data/test/mathematical/fixtures_test.rb +1 -1
- data/test/mathematical/maliciousness_test.rb +17 -17
- data/test/mathematical/mathjax_test.rb +2 -3
- data/test/mathematical/mathml_test.rb +1 -1
- data/test/mathematical/multiples_test.rb +1 -1
- data/test/mathematical/performance_test.rb +6 -8
- data/test/mathematical/png_test.rb +1 -1
- data/test/test_helper.rb +2 -2
- metadata +6 -6
data/lib/mathematical/version.rb
CHANGED
data/mathematical.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_development_dependency 'rake', '~> 0.9'
|
25
25
|
spec.add_development_dependency 'rake-compiler', '~> 0.9'
|
26
26
|
spec.add_development_dependency 'bundler', '~> 1.5'
|
27
|
-
spec.add_development_dependency '
|
27
|
+
spec.add_development_dependency 'minitest', '~> 5.6'
|
28
28
|
spec.add_development_dependency 'math-to-itex', '0.3.0'
|
29
29
|
spec.add_development_dependency 'nokogiri', '~> 1.6'
|
30
30
|
end
|
@@ -1,55 +1,55 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
|
3
|
-
class Mathematical::MaliciousnessTest < Test
|
3
|
+
class Mathematical::MaliciousnessTest < MiniTest::Test
|
4
4
|
|
5
5
|
def test_it_does_not_error_on_unrecognized_commands
|
6
6
|
render = Mathematical.new
|
7
7
|
output = nil
|
8
8
|
# In mtex2MML, we raise a ParseError, but Mathematical suppresses it and returns the string.
|
9
|
-
|
9
|
+
output = render.render('$not__thisisnotreal$')
|
10
10
|
assert_equal output[:data], '$not__thisisnotreal$'
|
11
11
|
assert_equal output[:exception].class, Mathematical::ParseError
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_it_does_not_blow_up_on_bad_arguments
|
15
15
|
# need to pass a hash here
|
16
|
-
|
16
|
+
assert_raises TypeError do
|
17
17
|
render = Mathematical.new("not a hash")
|
18
18
|
end
|
19
19
|
|
20
20
|
# need to pass a string here
|
21
21
|
render = Mathematical.new
|
22
|
-
|
22
|
+
assert_raises TypeError do
|
23
23
|
Mathematical.new.render(123)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_it_does_not_blow_up_on_bad_options
|
28
|
-
|
28
|
+
assert_raises TypeError do
|
29
29
|
Mathematical.new({:ppi => 'not a number'})
|
30
30
|
end
|
31
31
|
|
32
|
-
|
32
|
+
assert_raises TypeError do
|
33
33
|
render = Mathematical.new({:zoom => 'not a number'})
|
34
34
|
end
|
35
35
|
|
36
|
-
|
36
|
+
assert_raises TypeError do
|
37
37
|
Mathematical.new({:maxsize => 'not a number'})
|
38
38
|
end
|
39
39
|
|
40
|
-
|
40
|
+
assert_raises TypeError do
|
41
41
|
Mathematical.new({:maxsize => -23})
|
42
42
|
end
|
43
43
|
|
44
|
-
|
44
|
+
assert_raises TypeError do
|
45
45
|
Mathematical.new({:maxsize => 5.3})
|
46
46
|
end
|
47
47
|
|
48
|
-
|
48
|
+
assert_raises TypeError do
|
49
49
|
Mathematical.new({:format => 123})
|
50
50
|
end
|
51
51
|
|
52
|
-
|
52
|
+
assert_raises TypeError do
|
53
53
|
Mathematical.new({:format => 'something amazing'})
|
54
54
|
end
|
55
55
|
|
@@ -58,27 +58,27 @@ class Mathematical::MaliciousnessTest < Test::Unit::TestCase
|
|
58
58
|
assert_equal output[:data], '$a \ne b$'
|
59
59
|
assert_equal output[:exception].class, Mathematical::MaxsizeError
|
60
60
|
|
61
|
-
|
61
|
+
assert_raises RangeError do
|
62
62
|
render = Mathematical.new({ :maxsize => 4_294_967_295 }) # unsigned long max
|
63
63
|
render.render('$a \ne b$')
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
67
|
def test_it_does_not_blow_up_on_bad_input
|
68
|
-
|
68
|
+
assert_raises TypeError do
|
69
69
|
Mathematical.new.render(23)
|
70
70
|
end
|
71
71
|
|
72
|
-
|
72
|
+
assert_raises ArgumentError do
|
73
73
|
Mathematical.new.render('No dollars')
|
74
74
|
end
|
75
75
|
|
76
|
-
|
76
|
+
assert_raises ArgumentError do
|
77
77
|
array = %w(foof poof)
|
78
78
|
Mathematical.new.render(array)
|
79
79
|
end
|
80
80
|
|
81
|
-
|
81
|
+
assert_raises ArgumentError do
|
82
82
|
array = ['$foof$', nil, '$poof$']
|
83
83
|
Mathematical.new.render(array)
|
84
84
|
end
|
@@ -89,7 +89,7 @@ class Mathematical::MaliciousnessTest < Test::Unit::TestCase
|
|
89
89
|
output = nil
|
90
90
|
# Much like above, this fails in mtx2MML, but should do nothing here
|
91
91
|
text = '$\Huge \sqrt\sqrt\sqrt\sqrt\sqrt\sqrt\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}'
|
92
|
-
|
92
|
+
output = render.render(text)
|
93
93
|
assert_equal output[:data], text
|
94
94
|
assert_equal output[:exception].class, Mathematical::ParseError
|
95
95
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
require 'nokogiri'
|
3
3
|
|
4
|
-
class Mathematical::MathJaxTest < Test
|
4
|
+
class Mathematical::MathJaxTest < MiniTest::Test
|
5
5
|
|
6
6
|
render_svg = Mathematical.new
|
7
7
|
|
@@ -12,8 +12,7 @@ class Mathematical::MathJaxTest < Test::Unit::TestCase
|
|
12
12
|
Dir["#{MATHJAX_TEST_TEX_DIR}/**/*.tex"].each do |tex|
|
13
13
|
define_method "test_#{tex}" do
|
14
14
|
tex_contents = File.read(tex)
|
15
|
-
data =
|
16
|
-
assert_nothing_raised { data = render_svg.render(tex_contents) }
|
15
|
+
data = render_svg.render(tex_contents)
|
17
16
|
|
18
17
|
# assert the SVG actually rendered
|
19
18
|
doc = Nokogiri::HTML(data[:data])
|
@@ -1,15 +1,13 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
require 'benchmark'
|
3
3
|
|
4
|
-
class Mathematical::BasicTest < Test
|
4
|
+
class Mathematical::BasicTest < MiniTest::Test
|
5
5
|
def test_it_handles_big_files
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
MathToItex(big_file).convert { |equation| Mathematical.new.render(equation) }
|
10
|
-
end
|
11
|
-
|
12
|
-
assert_operator speed, :<=, 5
|
6
|
+
big_file = File.read('test/mathematical/fixtures/performance/big_file.text')
|
7
|
+
speed = Benchmark.realtime do
|
8
|
+
MathToItex(big_file).convert { |equation| Mathematical.new.render(equation) }
|
13
9
|
end
|
10
|
+
|
11
|
+
assert_operator speed, :<=, 5
|
14
12
|
end
|
15
13
|
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mathematical
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Garen Torikian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -53,19 +53,19 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.5'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: minitest
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '5.6'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '5.6'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: math-to-itex
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -418,7 +418,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
418
418
|
version: '0'
|
419
419
|
requirements: []
|
420
420
|
rubyforge_project:
|
421
|
-
rubygems_version: 2.2.
|
421
|
+
rubygems_version: 2.2.3
|
422
422
|
signing_key:
|
423
423
|
specification_version: 4
|
424
424
|
summary: '["Quickly", "convert", "math", "equations", "into", "beautiful", "SVGs/PNGs/MathML."]'
|