mathematical 0.2.3 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7879c51d6eaac8879a5ea40e28edb41a820bb106
4
- data.tar.gz: c2dfe304c21fe5d3d48c2948da6401a8f370bb78
3
+ metadata.gz: 64f77221486f047ae17b6854e592c37646728e5c
4
+ data.tar.gz: fbd33b15d71ee8b8da0deadd2ca6d18df91b842e
5
5
  SHA512:
6
- metadata.gz: 98785f651de7f6b5a0182e5a24ef1e5dcf739b06885ecb4d9956ba38a9cf0ba0699b20daec6066022cd98085a0eb8113f18e9f6b375017092c8445a14aece103
7
- data.tar.gz: 809e89e1c818cea062244523aca73c237a08eacc88844cf03035d806c426686d86d79e99020f8b6b3def2fd6116a61a81a239fb5439939c72bd997f3562a4c39
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
- The output will be the math equation, as an SVG blob.
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
- return rb_str_new2(readFile(tempfile));
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() {
@@ -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
- svg_content = File.open(tempfile.path, 'r') { |image_file| image_file.read }
27
- svg_content = svg_content[xml_header.length..-1] # remove starting <?xml...> tag
28
- @config[:base64] ? svg_to_base64(svg_content) : svg_content
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
@@ -1,3 +1,3 @@
1
1
  module Mathematical
2
- VERSION = "0.2.3"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -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.2.3
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-13 00:00:00.000000000 Z
11
+ date: 2014-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler