latex-decode 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ Njg4ZWIyZGNmNTc1ZWNjNWE0ZGFkZjdmNzFlZmMwNmM5YWZkZjRlNg==
5
+ data.tar.gz: !binary |-
6
+ MDEzM2E3ZGI2NzFhYmU5MmI3OGMxMTljMDdmNWMzMWFiYWMyNjIzZg==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ NDExYjMyNjdmYmU5OWYxMjNmMmE5OTZjNWIyNmIwOTcxNGZlYzQwMjc4OGE5
10
+ NDJiYjdkMWQyN2JlN2FhMDYzZWRiMTFmMmM2YWQ0NTJjNjJjMmNjNzEzODNm
11
+ NGFjNTVlODhlNDUxYjc2YmQxNDA4YTliMmE5M2U4NDljNWJlNGI=
12
+ data.tar.gz: !binary |-
13
+ NDZiMzJkMTRkZjY1OWRlYzJlYzk3YTU0NzhhOTVkZTIwYWVhM2MxNWQ1OWFh
14
+ YzY1ZDhiNzhhMWU5YzVhM2M1MWVmZjNkZjUyZmE1NDIxM2Y3MjBhY2MxY2Ji
15
+ MmY3MzYwOTI4MGFjYWNkOTY5NjU5M2NhZmZlMWQ1MzczNDFkZWU=
@@ -1,11 +1,12 @@
1
1
  language: ruby
2
+ bundler_args: --without debug
2
3
  rvm:
3
4
  - 1.9.3
4
5
  - 1.9.2
5
6
  - 2.0.0
6
7
  - jruby-18mode
7
8
  - jruby-19mode
8
- - rbx-18mode
9
+ # - rbx-18mode
9
10
  - rbx-19mode
10
11
  - ruby-head
11
12
  - jruby-head
@@ -16,7 +17,3 @@ notifications:
16
17
  - sk@semicolon.at
17
18
  on_success: change
18
19
  on_failure: always
19
- matrix:
20
- allow_failures:
21
- rvm:
22
- - rbx-18mode
data/Gemfile CHANGED
@@ -1,11 +1,17 @@
1
1
  source 'https://rubygems.org'
2
2
  gemspec
3
3
 
4
- group :development do
5
- gem 'ruby-debug19', :require => 'ruby-debug', :platforms => [:mri_19]
6
- gem 'ruby-debug', :platforms => [:mri_18]
4
+ group :test do
5
+ gem 'rake'
6
+ gem 'rspec', '~> 2.13'
7
+ gem 'cucumber', '~> 1.2'
7
8
  end
8
9
 
9
- gem 'rake', :groups => [:test, :development]
10
+ group :debug do
11
+ gem 'debugger', :platforms => [:mri_19, :mri_20]
12
+ gem 'ruby-debug', :platforms => [:mri_18]
13
+ end
10
14
 
11
15
  gem 'unicode', '~> 0.4', :platforms => [:mri, :rbx, :mswin, :mingw]
16
+
17
+ gem 'ritex', '~> 1.0.1'
data/Rakefile CHANGED
@@ -32,8 +32,9 @@ task :release do |t|
32
32
  system "git tag #{LaTeX::Decode::VERSION}"
33
33
  system "git push --tags"
34
34
  system "gem push latex-decode-#{LaTeX::Decode::VERSION}.gem"
35
- system "gem push latex-decode-#{LaTeX::Decode::VERSION}-java.gem"
36
35
  system "rm latex-decode-#{LaTeX::Decode::VERSION}.gem"
36
+ system "jgem build latex-decode.gemspec"
37
+ system "jgem push latex-decode-#{LaTeX::Decode::VERSION}.gem"
37
38
  system "rm latex-decode-#{LaTeX::Decode::VERSION}-java.gem"
38
39
  end
39
40
 
@@ -0,0 +1,9 @@
1
+ # Feature: Convert LaTeX maths to MathML
2
+ # As a maths-inclined hacker who works with LaTeX
3
+ # I want to convert LaTeX maths to MathML
4
+ #
5
+ # Scenario: Inline maths environment
6
+ # When I decode the string '$I_{S}A$'
7
+ # Then the result should be '<msub><mi>I</mi><mrow><mi>S</mi></mrow></msub><mi>A</mi>'
8
+ # When I decode the string '\underline{firstName LastName$3^g$}'
9
+ # Then the result should be ''
@@ -1,6 +1,6 @@
1
1
  Feature: Keep non-LaTeX markup as it is
2
2
  As a hacker who works with LaTeX
3
- I want to be preserve non-LaTeX text as it is
3
+ I want to preserve non-LaTeX text as it is
4
4
 
5
5
  Scenario: Standalone escape characters
6
6
  When I decode the string '\\'
@@ -11,6 +11,7 @@ Feature: Decode LaTeX special characters
11
11
  | \\\& | & |
12
12
  | \\# | # |
13
13
  | \\$ | $ |
14
+ | \\; | ; |
14
15
  | \\% | % |
15
16
  | \\{ | { |
16
17
  | \\} | } |
@@ -1 +1,7 @@
1
- require 'latex/decode'
1
+ begin
2
+ require 'debugger'
3
+ rescue LoadError
4
+ # ignore
5
+ end
6
+
7
+ require 'latex/decode'
@@ -21,10 +21,6 @@ Gem::Specification.new do |s|
21
21
  s.platform = 'ruby'
22
22
  end
23
23
 
24
- s.add_development_dependency('bundler', '~> 1.0')
25
- s.add_development_dependency('rspec', '~> 2.6')
26
- s.add_development_dependency('cucumber', "~> 1.0")
27
-
28
24
  s.files = `git ls-files`.split("\n")
29
25
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
30
26
  s.executables = []
@@ -1,18 +1,18 @@
1
1
  #--
2
2
  # LaTeX::Decode
3
- # Copyright (C) 2011 Sylvester Keil <sylvester.keil.or.at>
3
+ # Copyright (C) 2011-2013 Sylvester Keil <sylvester.keil.or.at>
4
4
  # Copyright (C) 2010 François Charette
5
- #
5
+ #
6
6
  # This program is free software: you can redistribute it and/or modify
7
7
  # it under the terms of the GNU General Public License as published by
8
8
  # the Free Software Foundation, either version 3 of the License, or
9
9
  # (at your option) any later version.
10
- #
10
+ #
11
11
  # This program is distributed in the hope that it will be useful,
12
12
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
13
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
14
  # GNU General Public License for more details.
15
- #
15
+ #
16
16
  # You should have received a copy of the GNU General Public License
17
17
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
18
18
  #++
@@ -23,26 +23,29 @@ require 'latex/decode/base'
23
23
 
24
24
  require 'latex/decode/accents'
25
25
  require 'latex/decode/diacritics'
26
+ require 'latex/decode/maths'
26
27
  require 'latex/decode/punctuation'
27
28
  require 'latex/decode/symbols'
28
29
 
29
30
  module LaTeX
30
-
31
+
31
32
  class << self
32
33
  def decode (string)
33
34
  return string unless string.respond_to?(:to_s)
34
35
 
35
36
  string = string.is_a?(String) ? string.dup : string.to_s
36
-
37
+
37
38
  Decode::Base.normalize(string)
38
-
39
+
40
+ Decode::Maths.decode!(string)
41
+
39
42
  Decode::Accents.decode!(string)
40
43
  Decode::Diacritics.decode!(string)
41
44
  Decode::Punctuation.decode!(string)
42
45
  Decode::Symbols.decode!(string)
43
-
46
+
44
47
  Decode::Base.strip_braces(string)
45
-
48
+
46
49
  LaTeX.normalize_C(string)
47
50
  end
48
51
  end
@@ -20,7 +20,6 @@ module LaTeX
20
20
  end
21
21
 
22
22
  def decode! (string)
23
- puts name unless patterns
24
23
  patterns.each do |pattern|
25
24
  string.gsub!(pattern) { |m| [$2,map[$1],$3].compact.join }
26
25
  end
@@ -14,8 +14,8 @@ else
14
14
 
15
15
  module LaTeX
16
16
  def self.to_unicode(string)
17
- string
18
- end
17
+ string
18
+ end
19
19
  end
20
20
 
21
21
  def ruby_18; false; end
@@ -33,9 +33,8 @@ if RUBY_PLATFORM == 'java'
33
33
  end
34
34
 
35
35
  else
36
-
37
- begin
38
- require 'unicode'
36
+ begin
37
+ require 'unicode'
39
38
 
40
39
  # Use the Unicode gem
41
40
  module LaTeX
@@ -43,7 +42,7 @@ else
43
42
  Unicode::normalize_C(string)
44
43
  end
45
44
  end
46
- rescue LoadError
45
+ rescue LoadError
47
46
  begin
48
47
  require 'active_support/multibyte/chars'
49
48
 
@@ -54,8 +53,37 @@ else
54
53
  end
55
54
  end
56
55
  rescue LoadError
57
- fail "Failed to load unicode normalizer: please gem install unicode (or active_support)"
56
+ fail "Failed to load unicode normalizer: please gem install unicode (or active_support)"
57
+ end
58
+ end
59
+ end
60
+
61
+ module LaTeX
62
+ begin
63
+ require 'ritex'
64
+
65
+ def self.ritex
66
+ Ritex::Parser.new(:mathml)
58
67
  end
59
- end
60
68
 
61
- end
69
+ def self.to_math_ml(string)
70
+ ritex.parse string, :nowrap => true, :display => false
71
+ end
72
+
73
+ rescue LoadError
74
+ begin
75
+ require 'math_ml'
76
+
77
+ def self.to_math_ml(string)
78
+ MathML::String.mathml_latex_parser.parse(string, false)
79
+ end
80
+
81
+ rescue LoadError
82
+ # No MathML conversion
83
+
84
+ def self.to_math_ml(string)
85
+ string
86
+ end
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,21 @@
1
+ module LaTeX
2
+ module Decode
3
+
4
+ class Maths < Decoder
5
+ @patterns = [
6
+ /\$([^\$]+)\$/
7
+ ].freeze
8
+
9
+ def self.decode! (string)
10
+ patterns.each do |pattern|
11
+ string.gsub!(pattern) do
12
+ LaTeX.to_math_ml($1)
13
+ end
14
+ end
15
+ string
16
+ end
17
+
18
+ end
19
+
20
+ end
21
+ end
@@ -47,7 +47,7 @@ module LaTeX
47
47
  @patterns = [
48
48
  /\\(#{ @macros.keys.map { |k| Regexp.escape(k) }.compact.join('|') })(?:\{\}|\s+|\b|$)/ou,
49
49
  /(-+|`{1,2}|'{1,2})/,
50
- /()\\([$%#_&])(\{\})?/,
50
+ /()\\([$%;#_&])(\{\})?/,
51
51
  /()\\(~)\{\}/
52
52
  ].freeze
53
53
 
@@ -1,5 +1,5 @@
1
1
  module LaTeX
2
2
  module Decode
3
- VERSION = '0.1.0'.freeze
3
+ VERSION = '0.1.1'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: latex-decode
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
5
- prerelease:
4
+ version: 0.1.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Sylvester Keil
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-02-26 00:00:00.000000000 Z
11
+ date: 2013-05-06 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: unicode
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,59 +20,10 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0.4'
30
- - !ruby/object:Gem::Dependency
31
- name: bundler
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ~>
36
- - !ruby/object:Gem::Version
37
- version: '1.0'
38
- type: :development
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ~>
44
- - !ruby/object:Gem::Version
45
- version: '1.0'
46
- - !ruby/object:Gem::Dependency
47
- name: rspec
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ~>
52
- - !ruby/object:Gem::Version
53
- version: '2.6'
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ~>
60
- - !ruby/object:Gem::Version
61
- version: '2.6'
62
- - !ruby/object:Gem::Dependency
63
- name: cucumber
64
- requirement: !ruby/object:Gem::Requirement
65
- none: false
66
- requirements:
67
- - - ~>
68
- - !ruby/object:Gem::Version
69
- version: '1.0'
70
- type: :development
71
- prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ~>
76
- - !ruby/object:Gem::Version
77
- version: '1.0'
78
27
  description: Decodes strings formatted in LaTeX to equivalent Unicode strings.
79
28
  email:
80
29
  - http://sylvester.keil.or.at
@@ -93,6 +42,7 @@ files:
93
42
  - cucumber.yml
94
43
  - features/brackets.feature
95
44
  - features/diacritics.feature
45
+ - features/maths.feature
96
46
  - features/non-latex.feature
97
47
  - features/punctuation.feature
98
48
  - features/special_characters.feature
@@ -105,12 +55,14 @@ files:
105
55
  - lib/latex/decode/base.rb
106
56
  - lib/latex/decode/compatibility.rb
107
57
  - lib/latex/decode/diacritics.rb
58
+ - lib/latex/decode/maths.rb
108
59
  - lib/latex/decode/punctuation.rb
109
60
  - lib/latex/decode/symbols.rb
110
61
  - lib/latex/decode/version.rb
111
62
  homepage: http://github.com/inukshuk/latex-decode
112
63
  licenses:
113
64
  - GPL-3
65
+ metadata: {}
114
66
  post_install_message:
115
67
  rdoc_options:
116
68
  - --line-numbers
@@ -123,35 +75,29 @@ rdoc_options:
123
75
  require_paths:
124
76
  - lib
125
77
  required_ruby_version: !ruby/object:Gem::Requirement
126
- none: false
127
78
  requirements:
128
79
  - - ! '>='
129
80
  - !ruby/object:Gem::Version
130
81
  version: '0'
131
- segments:
132
- - 0
133
- hash: -3992129943752612646
134
82
  required_rubygems_version: !ruby/object:Gem::Requirement
135
- none: false
136
83
  requirements:
137
84
  - - ! '>='
138
85
  - !ruby/object:Gem::Version
139
86
  version: '0'
140
- segments:
141
- - 0
142
- hash: -3992129943752612646
143
87
  requirements: []
144
88
  rubyforge_project:
145
- rubygems_version: 1.8.23
89
+ rubygems_version: 2.0.3
146
90
  signing_key:
147
- specification_version: 3
91
+ specification_version: 4
148
92
  summary: Decodes LaTeX to Unicode.
149
93
  test_files:
150
94
  - features/brackets.feature
151
95
  - features/diacritics.feature
96
+ - features/maths.feature
152
97
  - features/non-latex.feature
153
98
  - features/punctuation.feature
154
99
  - features/special_characters.feature
155
100
  - features/step_definitions/latex.rb
156
101
  - features/support/env.rb
157
102
  - features/umlauts.feature
103
+ has_rdoc: