mathematical 0.2.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -1
- data/ext/mathematical/mathematical.c +7 -1
- data/lib/mathematical/render.rb +4 -4
- data/lib/mathematical/version.rb +1 -1
- data/test/mathematical/fixtures_test.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 64f77221486f047ae17b6854e592c37646728e5c
|
4
|
+
data.tar.gz: fbd33b15d71ee8b8da0deadd2ca6d18df91b842e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1fab5176b65ad16c21871e62fab9c2c34625f3351b85a1e482f0bf02178779e74472fe59651b5c6918f263dec8c76eac6f5797d40bdb7af4fb3f3fcd7ab61a0
|
7
|
+
data.tar.gz: 11becede8f22950fc3d3c0c38a89ef9e1f8d47a67c422346753fb5be884aadf0af2794a8e2cd227bbb74e33d0e04e9e76f373138a777b46a7a8de308d5b74f58
|
data/README.md
CHANGED
@@ -29,7 +29,12 @@ Mathematical::Render.new.render(string_with_math)
|
|
29
29
|
```
|
30
30
|
|
31
31
|
`string_with_math` should just be a string of itex inline (`$..$`) or display (`$$..$$`) style math.
|
32
|
-
|
32
|
+
|
33
|
+
The output will be a hash, with the following data:
|
34
|
+
|
35
|
+
* `width`: the width of the resulting SVG file
|
36
|
+
* `height: the height of the resulting SVG file
|
37
|
+
* `svg`: the actual string of SVG
|
33
38
|
|
34
39
|
### Options
|
35
40
|
|
@@ -141,7 +141,13 @@ static VALUE MATHEMATICAL_process(VALUE self, VALUE rb_LatexCode, VALUE rb_TempF
|
|
141
141
|
|
142
142
|
if (svg_contents == NULL) rb_raise(rb_eDocumentReadError, "Failed to read SVG contents");
|
143
143
|
|
144
|
-
|
144
|
+
VALUE result_hash = rb_hash_new();
|
145
|
+
|
146
|
+
rb_hash_aset (result_hash, rb_tainted_str_new2 ("width"), INT2FIX(width_pt));
|
147
|
+
rb_hash_aset (result_hash, rb_tainted_str_new2 ("height"), INT2FIX(height_pt));
|
148
|
+
rb_hash_aset (result_hash, rb_tainted_str_new2 ("svg"), rb_str_new2(svg_contents));
|
149
|
+
|
150
|
+
return result_hash;
|
145
151
|
}
|
146
152
|
|
147
153
|
void Init_mathematical() {
|
data/lib/mathematical/render.rb
CHANGED
@@ -22,10 +22,10 @@ module Mathematical
|
|
22
22
|
# TODO: figure out how to write SVGs without the tempfile
|
23
23
|
tempfile = Tempfile.new('mathematical-temp.svg')
|
24
24
|
begin
|
25
|
-
raise RuntimeError unless @processer.process(maths, tempfile.path)
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
raise RuntimeError unless svg_hash = @processer.process(maths, tempfile.path)
|
26
|
+
svg_hash["svg"] = svg_hash["svg"][xml_header.length..-1] # remove starting <?xml...> tag
|
27
|
+
svg_hash["svg"] = svg_to_base64(svg_hash["svg"]) if @config[:base64]
|
28
|
+
svg_hash
|
29
29
|
rescue ParseError, DocumentCreationError, DocumentReadError => e # an error in the C code, probably a bad TeX parse
|
30
30
|
$stderr.puts "#{e.message}: #{maths}"
|
31
31
|
maths
|
data/lib/mathematical/version.rb
CHANGED
@@ -15,7 +15,7 @@ class Mathematical::FixturesTest < Test::Unit::TestCase
|
|
15
15
|
actual = MathToItex(source).convert do |eq, type|
|
16
16
|
svg_content = Mathematical::Render.new(:base64 => true).render(eq)
|
17
17
|
|
18
|
-
%|<img class="#{type.to_s}-math" data-math-type="#{type.to_s}-math" src="#{svg_content}"/>|
|
18
|
+
%|<img class="#{type.to_s}-math" data-math-type="#{type.to_s}-math" src="#{svg_content['svg']}"/>|
|
19
19
|
end.rstrip
|
20
20
|
|
21
21
|
expected_file = before.sub(/before/, "after").sub(/text/, "html")
|
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: 0.
|
4
|
+
version: 0.3.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: 2014-05-
|
11
|
+
date: 2014-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|