to_latex 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.4.0
@@ -5,7 +5,8 @@ module ToLatex
5
5
  "$" => "$",
6
6
  "$$" => "$$",
7
7
  "\\(" => "\\)",
8
- "\\[" => "\\]"
8
+ "\\[" => "\\]",
9
+ "\\ensuremath{" => "}"
9
10
  }
10
11
 
11
12
  def self.escape s
@@ -80,8 +81,8 @@ class Object
80
81
  to_s.to_latex
81
82
  end
82
83
 
83
- # Convert an object to latex with escaping and adding $ $ or other delimiter around
84
- def to_latex_math open = "$", close = nil
84
+ # Convert an object to latex with escaping and adding \ensuremath{}, $$ or other delimiter around
85
+ def to_latex_math open = "\\ensuremath{", close = nil
85
86
  close ||= ToLatex::DELIMITER_PAIRS[open] || open
86
87
  ToLatex::LatexString.new "#{open}#{to_latex}#{close}"
87
88
  end
@@ -4,7 +4,7 @@ describe "ToLatex" do
4
4
  specify "String#to_latex" do
5
5
  '%'.to_latex.should == '\%'
6
6
  '!'.to_latex.should == '!'
7
- '^'.to_latex.should == '\char94'
7
+ '^'.to_latex.should == '\^{}'
8
8
  'a'.to_latex.should == 'a'
9
9
 
10
10
  'a'.should_not be_latex
@@ -48,18 +48,16 @@ describe "ToLatex" do
48
48
  end
49
49
 
50
50
  specify "to_latex_math" do
51
- 5.to_latex_math.should == "$5$"
52
- 5.to_s.to_latex_math.should == "$5$"
53
- 5.to_s.to_latex.to_latex_math.should == "$5$"
54
- 5.to_s.to_latex.to_latex_math.to_latex.should == "$5$"
55
- "a".to_latex_math.should == "$a$"
56
- "a".to_s.to_latex_math.should == "$a$"
57
- "a".to_s.to_latex.to_latex_math.should == "$a$"
58
- "a".to_s.to_latex.to_latex_math.to_latex.should == "$a$"
59
- "5%".to_latex_math.should == "$5\\%$"
60
- "5%".to_s.to_latex_math.should == "$5\\%$"
61
- "5%".to_s.to_latex.to_latex_math.should == "$5\\%$"
62
- "5%".to_s.to_latex.to_latex_math.to_latex.should == "$5\\%$"
51
+ def check_to_latex_math source, result
52
+ source.to_latex_math.should == result
53
+ source.to_s.to_latex_math.should == result
54
+ source.to_s.to_latex.to_latex_math.should == result
55
+ source.to_s.to_latex.to_latex_math.to_latex.should == result
56
+ end
57
+
58
+ check_to_latex_math 5, "\\ensuremath{5}"
59
+ check_to_latex_math "a", "\\ensuremath{a}"
60
+ check_to_latex_math "5%", "\\ensuremath{5\\%}"
63
61
 
64
62
  "5%".to_latex_math("\\[").should == "\\[5\\%\\]"
65
63
  "5%".to_latex_math("\\(").should == "\\(5\\%\\)"
@@ -67,6 +65,7 @@ describe "ToLatex" do
67
65
  "5%".to_latex_math("$$").should == "$$5\\%$$"
68
66
  "5%".to_latex_math("a").should == "a5\\%a"
69
67
  "5%".to_latex_math("a","b").should == "a5\\%b"
68
+ "5%".to_latex_math("$","$").should == "$5\\%$"
70
69
  end
71
70
 
72
71
  specify "dup" do
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "to_latex"
8
- s.version = "0.3.1"
8
+ s.version = "0.4.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Bern\u{e1}t Kall\u{f3}"]
12
- s.date = "2012-03-26"
12
+ s.date = "2012-04-01"
13
13
  s.description = "Adds #to_latex to objects and strings. Works like html_safe in Rails 3, it escapes special characters as needed. Once converted, a string becomes a ToLatex::LatexString instance, with #latex? returning true, and never again will be escaped.\n \n You can concatenate any escaped or not escaped string to an escaped one, they get properly escaped.\n \n This gem powers texerb."
14
14
  s.email = "kallo.bernat@gmail.com"
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: to_latex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-26 00:00:00.000000000Z
12
+ date: 2012-04-01 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &87140620 !ruby/object:Gem::Requirement
16
+ requirement: &82239450 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 2.8.0
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *87140620
24
+ version_requirements: *82239450
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rdoc
27
- requirement: &87140140 !ruby/object:Gem::Requirement
27
+ requirement: &82239200 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '3.12'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *87140140
35
+ version_requirements: *82239200
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: bundler
38
- requirement: &87139520 !ruby/object:Gem::Requirement
38
+ requirement: &82238870 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.0.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *87139520
46
+ version_requirements: *82238870
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: jeweler
49
- requirement: &87139190 !ruby/object:Gem::Requirement
49
+ requirement: &82233380 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.8.3
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *87139190
57
+ version_requirements: *82233380
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rcov
60
- requirement: &87138840 !ruby/object:Gem::Requirement
60
+ requirement: &82233080 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *87138840
68
+ version_requirements: *82233080
69
69
  description: ! "Adds #to_latex to objects and strings. Works like html_safe in Rails
70
70
  3, it escapes special characters as needed. Once converted, a string becomes a ToLatex::LatexString
71
71
  instance, with #latex? returning true, and never again will be escaped.\n \n
@@ -105,7 +105,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
105
105
  version: '0'
106
106
  segments:
107
107
  - 0
108
- hash: 200503501
108
+ hash: -1070013009
109
109
  required_rubygems_version: !ruby/object:Gem::Requirement
110
110
  none: false
111
111
  requirements: