latex-decode 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -2,6 +2,9 @@ source :rubygems
2
2
  gemspec
3
3
 
4
4
  group :development do
5
- gem 'ruby-debug19', :require => 'ruby-debug', :platforms => [:ruby_19]
6
- gem 'ruby-debug', :platforms => [:ruby_18]
7
- end
5
+ gem 'ruby-debug19', :require => 'ruby-debug', :platforms => [:mri_19]
6
+ gem 'ruby-debug', :platforms => [:mri_18]
7
+ end
8
+
9
+
10
+ gem 'unicode', '~> 0.4', :platforms => [:mri, :rbx, :mswin, :mingw]
@@ -8,7 +8,6 @@ Feature: Decode LaTeX diacritics
8
8
 
9
9
  Scenarios: Diacritics
10
10
  | latex | unicode | description |
11
- | \\~{} | ~ | |
12
11
  | \\\`{o} | ò | grave accent |
13
12
  | \\\'{o} | ó | acute accent |
14
13
  | \\^{o} | ô | circumflex |
@@ -36,6 +36,7 @@ Feature: Decode LaTeX punctuation directives
36
36
  | - | - | hyphen |
37
37
  | -- | – | en-dash |
38
38
  | --- | — | em-dash |
39
+ | \\~{} | ~ | tilde |
39
40
 
40
41
  Scenarios: Quotation marks
41
42
  | latex | unicode | description |
@@ -15,6 +15,6 @@ Feature: Decode LaTeX special characters
15
15
  | \\{ | { |
16
16
  | \\} | } |
17
17
  | \\_ | _ |
18
- | \\~{} | ~ |
18
+ | \\textasciitilde{} | ~ |
19
19
  | \\textbackslash{} | \\ |
20
20
  | \\textasciicircum{} | ^ |
@@ -15,8 +15,6 @@ Gem::Specification.new do |s|
15
15
  s.description = 'Decodes strings formatted in LaTeX to equivalent Unicode strings.'
16
16
  s.license = 'GPL-3'
17
17
 
18
- s.add_runtime_dependency('unicode', '~> 0.4')
19
-
20
18
  s.add_development_dependency('rake', '~> 0.8')
21
19
  s.add_development_dependency('bundler', '~> 1.0')
22
20
  s.add_development_dependency('rdoc', '~> 3.6')
@@ -17,8 +17,6 @@
17
17
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
18
18
  #++
19
19
 
20
- require 'unicode'
21
-
22
20
  require 'latex/decode/version'
23
21
  require 'latex/decode/compatibility'
24
22
  require 'latex/decode/base'
@@ -45,7 +43,7 @@ module LaTeX
45
43
 
46
44
  Decode::Base.strip_braces(string)
47
45
 
48
- Unicode::normalize_C(string)
46
+ LaTeX.normalize_C(string)
49
47
  end
50
48
  end
51
49
  end
@@ -17,7 +17,7 @@ module LaTeX
17
17
 
18
18
  @patterns = [
19
19
  ruby_18 {
20
- /\\(#{ map.keys.map { |k| Regexp.escape(k) }.join('|') })\{([[:alpha:]]*)\}/ou
20
+ /\\(#{ map.keys.map { |k| Regexp.escape(k) }.join('|') })\{([[:alpha:]]+)\}/ou
21
21
  } ||
22
22
  ruby_19 {
23
23
  /\\(#{ map.keys.map { |k| Regexp.escape(k) }.join('|') })\{(\p{L}\p{M}*)\}/ou
@@ -18,4 +18,42 @@ else
18
18
 
19
19
  def ruby_18; false; end
20
20
  def ruby_19; yield; end
21
+ end
22
+
23
+ if RUBY_PLATFORM == 'java'
24
+ require 'java'
25
+
26
+ # Use the Java native Unicode normalizer
27
+ module LaTeX
28
+ def self.normalize_C(string)
29
+ java.text.Normalizer.normalize(string, java.text.Normalizer::Form::NFC).to_s
30
+ end
31
+ end
32
+
33
+ else
34
+
35
+ begin
36
+ require 'unicode'
37
+
38
+ # Use the Unicode gem
39
+ module LaTeX
40
+ def self.normalize_C(string)
41
+ Unicode::normalize_C(string)
42
+ end
43
+ end
44
+ rescue LoadError
45
+ begin
46
+ require 'active_support/multibyte/chars'
47
+
48
+ # Use ActiveSupport's normalizer
49
+ module LaTeX
50
+ def self.normalize_C(string)
51
+ ActiveSupport::Multibyte::Chars.new(string).normalize(:c).to_s
52
+ end
53
+ end
54
+ rescue LoadError
55
+ fail "Failed to load unicode normalizer: please gem install unicode (or active_support)"
56
+ end
57
+ end
58
+
21
59
  end
@@ -29,6 +29,7 @@ module LaTeX
29
29
  rangle ⟩
30
30
  textasciicircum ^
31
31
  textbackslash \\
32
+ textasciitilde ~
32
33
  }].freeze
33
34
 
34
35
  @symbols = Hash[*%w[
@@ -1,5 +1,5 @@
1
1
  module LaTeX
2
2
  module Decode
3
- VERSION = '0.0.10'.freeze
3
+ VERSION = '0.0.11'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: latex-decode
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,22 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-06 00:00:00.000000000 Z
12
+ date: 2012-01-31 00:00:00.000000000 Z
13
13
  dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: unicode
16
- requirement: &70305758476260 !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ~>
20
- - !ruby/object:Gem::Version
21
- version: '0.4'
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: *70305758476260
25
14
  - !ruby/object:Gem::Dependency
26
15
  name: rake
27
- requirement: &70305758475220 !ruby/object:Gem::Requirement
16
+ requirement: &70308628195760 !ruby/object:Gem::Requirement
28
17
  none: false
29
18
  requirements:
30
19
  - - ~>
@@ -32,10 +21,10 @@ dependencies:
32
21
  version: '0.8'
33
22
  type: :development
34
23
  prerelease: false
35
- version_requirements: *70305758475220
24
+ version_requirements: *70308628195760
36
25
  - !ruby/object:Gem::Dependency
37
26
  name: bundler
38
- requirement: &70305758473880 !ruby/object:Gem::Requirement
27
+ requirement: &70308628194620 !ruby/object:Gem::Requirement
39
28
  none: false
40
29
  requirements:
41
30
  - - ~>
@@ -43,10 +32,10 @@ dependencies:
43
32
  version: '1.0'
44
33
  type: :development
45
34
  prerelease: false
46
- version_requirements: *70305758473880
35
+ version_requirements: *70308628194620
47
36
  - !ruby/object:Gem::Dependency
48
37
  name: rdoc
49
- requirement: &70305758472780 !ruby/object:Gem::Requirement
38
+ requirement: &70308628193800 !ruby/object:Gem::Requirement
50
39
  none: false
51
40
  requirements:
52
41
  - - ~>
@@ -54,10 +43,10 @@ dependencies:
54
43
  version: '3.6'
55
44
  type: :development
56
45
  prerelease: false
57
- version_requirements: *70305758472780
46
+ version_requirements: *70308628193800
58
47
  - !ruby/object:Gem::Dependency
59
48
  name: rspec
60
- requirement: &70305758470880 !ruby/object:Gem::Requirement
49
+ requirement: &70308628213200 !ruby/object:Gem::Requirement
61
50
  none: false
62
51
  requirements:
63
52
  - - ~>
@@ -65,10 +54,10 @@ dependencies:
65
54
  version: '2.6'
66
55
  type: :development
67
56
  prerelease: false
68
- version_requirements: *70305758470880
57
+ version_requirements: *70308628213200
69
58
  - !ruby/object:Gem::Dependency
70
59
  name: cucumber
71
- requirement: &70305758469080 !ruby/object:Gem::Requirement
60
+ requirement: &70308628210800 !ruby/object:Gem::Requirement
72
61
  none: false
73
62
  requirements:
74
63
  - - ~>
@@ -76,7 +65,7 @@ dependencies:
76
65
  version: '1.0'
77
66
  type: :development
78
67
  prerelease: false
79
- version_requirements: *70305758469080
68
+ version_requirements: *70308628210800
80
69
  description: Decodes strings formatted in LaTeX to equivalent Unicode strings.
81
70
  email:
82
71
  - http://sylvester.keil.or.at