latex-decode 0.1.1 → 0.2.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 +6 -14
 - data/.gitignore +3 -0
 - data/.travis.yml +9 -10
 - data/Gemfile +9 -5
 - data/README.md +2 -2
 - data/Rakefile +1 -1
 - data/features/greek.feature +13 -0
 - data/features/maths.feature +1 -1
 - data/features/punctuation.feature +1 -0
 - data/features/step_definitions/latex.rb +2 -2
 - data/features/support/env.rb +9 -2
 - data/lib/latex/decode.rb +3 -1
 - data/lib/latex/decode/base.rb +13 -13
 - data/lib/latex/decode/compatibility.rb +7 -7
 - data/lib/latex/decode/greek.rb +61 -0
 - data/lib/latex/decode/maths.rb +3 -3
 - data/lib/latex/decode/punctuation.rb +7 -6
 - data/lib/latex/decode/symbols.rb +3 -3
 - data/lib/latex/decode/version.rb +2 -2
 - metadata +18 -15
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,15 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
              metadata.gz: !binary |-
         
     | 
| 
       9 
     | 
    
         
            -
                NDExYjMyNjdmYmU5OWYxMjNmMmE5OTZjNWIyNmIwOTcxNGZlYzQwMjc4OGE5
         
     | 
| 
       10 
     | 
    
         
            -
                NDJiYjdkMWQyN2JlN2FhMDYzZWRiMTFmMmM2YWQ0NTJjNjJjMmNjNzEzODNm
         
     | 
| 
       11 
     | 
    
         
            -
                NGFjNTVlODhlNDUxYjc2YmQxNDA4YTliMmE5M2U4NDljNWJlNGI=
         
     | 
| 
       12 
     | 
    
         
            -
              data.tar.gz: !binary |-
         
     | 
| 
       13 
     | 
    
         
            -
                NDZiMzJkMTRkZjY1OWRlYzJlYzk3YTU0NzhhOTVkZTIwYWVhM2MxNWQ1OWFh
         
     | 
| 
       14 
     | 
    
         
            -
                YzY1ZDhiNzhhMWU5YzVhM2M1MWVmZjNkZjUyZmE1NDIxM2Y3MjBhY2MxY2Ji
         
     | 
| 
       15 
     | 
    
         
            -
                MmY3MzYwOTI4MGFjYWNkOTY5NjU5M2NhZmZlMWQ1MzczNDFkZWU=
         
     | 
| 
      
 2 
     | 
    
         
            +
            SHA1:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 0d7ee959a3494ff7a4944bb79f65ce12c6d881dc
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 7f3199fd6301438401a8a1e9f94fb2cc5dc555e4
         
     | 
| 
      
 5 
     | 
    
         
            +
            SHA512:
         
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 41713ce86f026006771e711511bf002992a7c7da8abeca6c88e3c1885a3611ead9c98a7ac2795c94d86a7141718427d5875d98b3f3db18fecc76835cf301a13d
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 82a459edb974a2d31908d210f91acd1f7db64074d971df9716709ec62b3f7fb11cfa554bb14488101ed353b54d52c472a02361e0374ce2c9011f813a8f7b3c8e
         
     | 
    
        data/.gitignore
    CHANGED
    
    
    
        data/.travis.yml
    CHANGED
    
    | 
         @@ -1,19 +1,18 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            language: ruby
         
     | 
| 
       2 
2 
     | 
    
         
             
            bundler_args: --without debug
         
     | 
| 
      
 3 
     | 
    
         
            +
            sudo: false
         
     | 
| 
      
 4 
     | 
    
         
            +
            cache: bundler
         
     | 
| 
       3 
5 
     | 
    
         
             
            rvm:
         
     | 
| 
       4 
6 
     | 
    
         
             
              - 1.9.3
         
     | 
| 
       5 
     | 
    
         
            -
              - 1.9.2
         
     | 
| 
       6 
7 
     | 
    
         
             
              - 2.0.0
         
     | 
| 
       7 
     | 
    
         
            -
              -  
     | 
| 
      
 8 
     | 
    
         
            +
              - 2.1.0
         
     | 
| 
      
 9 
     | 
    
         
            +
              - 2.2.0
         
     | 
| 
       8 
10 
     | 
    
         
             
              - jruby-19mode
         
     | 
| 
       9 
     | 
    
         
            -
            #  - rbx-18mode
         
     | 
| 
       10 
     | 
    
         
            -
              - rbx-19mode
         
     | 
| 
       11 
     | 
    
         
            -
              - ruby-head
         
     | 
| 
       12 
11 
     | 
    
         
             
              - jruby-head
         
     | 
| 
       13 
     | 
    
         
            -
              -  
     | 
| 
       14 
     | 
    
         
            -
              - ree
         
     | 
| 
      
 12 
     | 
    
         
            +
              - rbx-2
         
     | 
| 
       15 
13 
     | 
    
         
             
            notifications:
         
     | 
| 
       16 
14 
     | 
    
         
             
              email:
         
     | 
| 
       17 
     | 
    
         
            -
                 
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
      
 15 
     | 
    
         
            +
                recipients:
         
     | 
| 
      
 16 
     | 
    
         
            +
                  - sylvester@keil.or.at
         
     | 
| 
      
 17 
     | 
    
         
            +
                on_success: change
         
     | 
| 
      
 18 
     | 
    
         
            +
                on_failure: always
         
     | 
    
        data/Gemfile
    CHANGED
    
    | 
         @@ -3,15 +3,19 @@ gemspec 
     | 
|
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         
             
            group :test do
         
     | 
| 
       5 
5 
     | 
    
         
             
              gem 'rake'
         
     | 
| 
       6 
     | 
    
         
            -
              gem 'rspec', '~>  
     | 
| 
       7 
     | 
    
         
            -
              gem 'cucumber', '~> 1. 
     | 
| 
      
 6 
     | 
    
         
            +
              gem 'rspec', '~> 3.0'
         
     | 
| 
      
 7 
     | 
    
         
            +
              gem 'cucumber', '~> 1.3'
         
     | 
| 
       8 
8 
     | 
    
         
             
            end
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
            group :debug do
         
     | 
| 
       11 
     | 
    
         
            -
            	gem 'debugger', :platforms =>  
     | 
| 
       12 
     | 
    
         
            -
            	gem ' 
     | 
| 
      
 11 
     | 
    
         
            +
            	gem 'debugger', :platforms => :mri_19
         
     | 
| 
      
 12 
     | 
    
         
            +
            	gem 'byebug', :platforms => :mri if RUBY_VERSION > '2.0'
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
              gem 'rubinius-debugger', :require => false, :platforms => :rbx
         
     | 
| 
      
 15 
     | 
    
         
            +
              gem 'rubinius-compiler', :require => false, :platforms => :rbx
         
     | 
| 
       13 
16 
     | 
    
         
             
            end
         
     | 
| 
       14 
17 
     | 
    
         | 
| 
       15 
18 
     | 
    
         
             
            gem 'unicode', '~> 0.4', :platforms => [:mri, :rbx, :mswin, :mingw]
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
19 
     | 
    
         
             
            gem 'ritex', '~> 1.0.1'
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
            gem 'rubysl', '~> 2.0', :platforms => :rbx
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -36,7 +36,7 @@ describe the example above as: 
     | 
|
| 
       36 
36 
     | 
    
         
             
                Feature: Decode LaTeX accents
         
     | 
| 
       37 
37 
     | 
    
         
             
                  As a hacker who works with LaTeX
         
     | 
| 
       38 
38 
     | 
    
         
             
                  I want to be able to decode LaTeX accents
         
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
       40 
40 
     | 
    
         
             
                  Scenario: A French sentence
         
     | 
| 
       41 
41 
     | 
    
         
             
                    When I decode the string "dipl\\^{o}me d'\\'{e}tudes sup\\'erieures"
         
     | 
| 
       42 
42 
     | 
    
         
             
                    Then the result should be "diplôme d'études supérieures"
         
     | 
| 
         @@ -47,7 +47,7 @@ Credits 
     | 
|
| 
       47 
47 
     | 
    
         
             
            Kudos and thanks to all [contributors](https://github.com/inukshuk/latex-decode/contributors)
         
     | 
| 
       48 
48 
     | 
    
         
             
            who have made LaTeX::Decode possible!
         
     | 
| 
       49 
49 
     | 
    
         | 
| 
       50 
     | 
    
         
            -
            Copyright (C) 2011- 
     | 
| 
      
 50 
     | 
    
         
            +
            Copyright (C) 2011-2015 [Sylvester Keil](sylvester.keil.or.at)
         
     | 
| 
       51 
51 
     | 
    
         | 
| 
       52 
52 
     | 
    
         
             
            Copyright (C) 2010 François Charette
         
     | 
| 
       53 
53 
     | 
    
         | 
    
        data/Rakefile
    CHANGED
    
    
| 
         @@ -0,0 +1,13 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Feature: Decode LaTeX Greek Letters
         
     | 
| 
      
 2 
     | 
    
         
            +
              As a hacker who works with LaTeX
         
     | 
| 
      
 3 
     | 
    
         
            +
              I want to be able to decode Greek letters
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
              Scenario Outline: LaTeX to Unicode transformation
         
     | 
| 
      
 6 
     | 
    
         
            +
                When I decode the string '<latex>'
         
     | 
| 
      
 7 
     | 
    
         
            +
                Then the result should be '<unicode>'
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
              Scenarios: Greek
         
     | 
| 
      
 10 
     | 
    
         
            +
                | latex                | unicode |
         
     | 
| 
      
 11 
     | 
    
         
            +
                | \\alpha              | α       |
         
     | 
| 
      
 12 
     | 
    
         
            +
                | \\lambda             | λ       |
         
     | 
| 
      
 13 
     | 
    
         
            +
                | \\Lambda             | Λ       |
         
     | 
    
        data/features/maths.feature
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # Feature: Convert LaTeX maths to MathML
         
     | 
| 
       2 
2 
     | 
    
         
             
            #   As a maths-inclined hacker who works with LaTeX
         
     | 
| 
       3 
3 
     | 
    
         
             
            #   I want to convert LaTeX maths to MathML
         
     | 
| 
       4 
     | 
    
         
            -
            # 
     | 
| 
      
 4 
     | 
    
         
            +
            #
         
     | 
| 
       5 
5 
     | 
    
         
             
            #   Scenario: Inline maths environment
         
     | 
| 
       6 
6 
     | 
    
         
             
            #     When I decode the string '$I_{S}A$'
         
     | 
| 
       7 
7 
     | 
    
         
             
            #     Then the result should be '<msub><mi>I</mi><mrow><mi>S</mi></mrow></msub><mi>A</mi>'
         
     | 
    
        data/features/support/env.rb
    CHANGED
    
    | 
         @@ -1,7 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            begin
         
     | 
| 
       2 
     | 
    
         
            -
               
     | 
| 
      
 2 
     | 
    
         
            +
              case
         
     | 
| 
      
 3 
     | 
    
         
            +
              when defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
         
     | 
| 
      
 4 
     | 
    
         
            +
                require 'rubinius/debugger'
         
     | 
| 
      
 5 
     | 
    
         
            +
              when RUBY_VERSION > '2.0'
         
     | 
| 
      
 6 
     | 
    
         
            +
                require 'byebug'
         
     | 
| 
      
 7 
     | 
    
         
            +
              else
         
     | 
| 
      
 8 
     | 
    
         
            +
                require 'debugger'
         
     | 
| 
      
 9 
     | 
    
         
            +
              end
         
     | 
| 
       3 
10 
     | 
    
         
             
            rescue LoadError
         
     | 
| 
       4 
11 
     | 
    
         
             
              # ignore
         
     | 
| 
       5 
12 
     | 
    
         
             
            end
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
       7 
14 
     | 
    
         
             
            require 'latex/decode'
         
     | 
    
        data/lib/latex/decode.rb
    CHANGED
    
    | 
         @@ -26,6 +26,7 @@ require 'latex/decode/diacritics' 
     | 
|
| 
       26 
26 
     | 
    
         
             
            require 'latex/decode/maths'
         
     | 
| 
       27 
27 
     | 
    
         
             
            require 'latex/decode/punctuation'
         
     | 
| 
       28 
28 
     | 
    
         
             
            require 'latex/decode/symbols'
         
     | 
| 
      
 29 
     | 
    
         
            +
            require 'latex/decode/greek'
         
     | 
| 
       29 
30 
     | 
    
         | 
| 
       30 
31 
     | 
    
         
             
            module LaTeX
         
     | 
| 
       31 
32 
     | 
    
         | 
| 
         @@ -43,10 +44,11 @@ module LaTeX 
     | 
|
| 
       43 
44 
     | 
    
         
             
                  Decode::Diacritics.decode!(string)
         
     | 
| 
       44 
45 
     | 
    
         
             
                  Decode::Punctuation.decode!(string)
         
     | 
| 
       45 
46 
     | 
    
         
             
                  Decode::Symbols.decode!(string)
         
     | 
| 
      
 47 
     | 
    
         
            +
                  Decode::Greek.decode!(string)
         
     | 
| 
       46 
48 
     | 
    
         | 
| 
       47 
49 
     | 
    
         
             
                  Decode::Base.strip_braces(string)
         
     | 
| 
       48 
50 
     | 
    
         | 
| 
       49 
51 
     | 
    
         
             
                  LaTeX.normalize_C(string)
         
     | 
| 
       50 
52 
     | 
    
         
             
                end
         
     | 
| 
       51 
53 
     | 
    
         
             
              end
         
     | 
| 
       52 
     | 
    
         
            -
            end
         
     | 
| 
      
 54 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/latex/decode/base.rb
    CHANGED
    
    | 
         @@ -2,23 +2,23 @@ 
     | 
|
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            module LaTeX
         
     | 
| 
       4 
4 
     | 
    
         
             
              module Decode
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
       6 
6 
     | 
    
         
             
                class Decoder
         
     | 
| 
       7 
7 
     | 
    
         
             
                  class << self
         
     | 
| 
       8 
8 
     | 
    
         
             
                    attr_reader :patterns, :map
         
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
       10 
10 
     | 
    
         
             
                    def inherited (base)
         
     | 
| 
       11 
11 
     | 
    
         
             
                      subclasses << base
         
     | 
| 
       12 
12 
     | 
    
         
             
                    end
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
       14 
14 
     | 
    
         
             
                    def subclasses
         
     | 
| 
       15 
15 
     | 
    
         
             
                      @subclasses ||= []
         
     | 
| 
       16 
16 
     | 
    
         
             
                    end
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
       18 
18 
     | 
    
         
             
                    def decode (string)
         
     | 
| 
       19 
19 
     | 
    
         
             
                      decode!(string.dup)
         
     | 
| 
       20 
20 
     | 
    
         
             
                    end
         
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
       22 
22 
     | 
    
         
             
                    def decode! (string)
         
     | 
| 
       23 
23 
     | 
    
         
             
                      patterns.each do |pattern|
         
     | 
| 
       24 
24 
     | 
    
         
             
                        string.gsub!(pattern) { |m| [$2,map[$1],$3].compact.join }
         
     | 
| 
         @@ -27,11 +27,11 @@ module LaTeX 
     | 
|
| 
       27 
27 
     | 
    
         
             
                    end
         
     | 
| 
       28 
28 
     | 
    
         
             
                  end
         
     | 
| 
       29 
29 
     | 
    
         
             
                end
         
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
       31 
31 
     | 
    
         
             
                module Base
         
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
       33 
33 
     | 
    
         
             
                  module_function
         
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
       35 
35 
     | 
    
         
             
                  def normalize (string)
         
     | 
| 
       36 
36 
     | 
    
         
             
                    string.gsub!(/\\(?:i|j)\b/) { |m| m == '\\i' ? 'ı' : 'ȷ' }
         
     | 
| 
       37 
37 
     | 
    
         | 
| 
         @@ -43,17 +43,17 @@ module LaTeX 
     | 
|
| 
       43 
43 
     | 
    
         | 
| 
       44 
44 
     | 
    
         
             
            				# \c cb -> \c{cb}
         
     | 
| 
       45 
45 
     | 
    
         
             
                    string.gsub!(/(\\[^\sij&#\$\{\}_~%])\s+([[:alpha:]]+)\b/i, '\1{\2}')
         
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
       47 
47 
     | 
    
         
             
                    string
         
     | 
| 
       48 
48 
     | 
    
         
             
                  end
         
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
       50 
50 
     | 
    
         
             
                  def strip_braces (string)
         
     | 
| 
       51 
51 
     | 
    
         
             
                    string.gsub!(/(^|[^\\])([\{\}]+)/, '\1')
         
     | 
| 
       52 
52 
     | 
    
         
             
                    string.gsub!(/\\(\{|\})/, '\1')
         
     | 
| 
       53 
53 
     | 
    
         
             
                    string
         
     | 
| 
       54 
54 
     | 
    
         
             
                  end
         
     | 
| 
       55 
     | 
    
         
            -
             
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
       56 
56 
     | 
    
         
             
                end
         
     | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
       58 
58 
     | 
    
         
             
              end
         
     | 
| 
       59 
     | 
    
         
            -
            end
         
     | 
| 
      
 59 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -1,16 +1,16 @@ 
     | 
|
| 
       1 
1 
     | 
    
         | 
| 
       2 
2 
     | 
    
         
             
            if RUBY_VERSION < "1.9"
         
     | 
| 
       3 
3 
     | 
    
         
             
              $KCODE = 'U'
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
       5 
5 
     | 
    
         
             
              module LaTeX
         
     | 
| 
       6 
6 
     | 
    
         
             
                def self.to_unicode(string)
         
     | 
| 
       7 
7 
     | 
    
         
             
                  string.gsub(/\\?u([\da-f]{4})/i) { |m| [$1.to_i(16)].pack('U') }
         
     | 
| 
       8 
8 
     | 
    
         
             
                end
         
     | 
| 
       9 
9 
     | 
    
         
             
              end
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
       11 
11 
     | 
    
         
             
              def ruby_18; yield; end
         
     | 
| 
       12 
12 
     | 
    
         
             
              def ruby_19; false; end
         
     | 
| 
       13 
     | 
    
         
            -
            else 
     | 
| 
      
 13 
     | 
    
         
            +
            else
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
15 
     | 
    
         
             
              module LaTeX
         
     | 
| 
       16 
16 
     | 
    
         
             
                def self.to_unicode(string)
         
     | 
| 
         @@ -24,14 +24,14 @@ end 
     | 
|
| 
       24 
24 
     | 
    
         | 
| 
       25 
25 
     | 
    
         
             
            if RUBY_PLATFORM == 'java'
         
     | 
| 
       26 
26 
     | 
    
         
             
              require 'java'
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
       28 
28 
     | 
    
         
             
              # Use the Java native Unicode normalizer
         
     | 
| 
       29 
29 
     | 
    
         
             
              module LaTeX
         
     | 
| 
       30 
30 
     | 
    
         
             
                def self.normalize_C(string)
         
     | 
| 
       31 
31 
     | 
    
         
             
                  java.text.Normalizer.normalize(string, java.text.Normalizer::Form::NFC).to_s
         
     | 
| 
       32 
32 
     | 
    
         
             
                end
         
     | 
| 
       33 
33 
     | 
    
         
             
              end
         
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
       35 
35 
     | 
    
         
             
            else
         
     | 
| 
       36 
36 
     | 
    
         
             
              begin
         
     | 
| 
       37 
37 
     | 
    
         
             
                require 'unicode'
         
     | 
| 
         @@ -45,7 +45,7 @@ else 
     | 
|
| 
       45 
45 
     | 
    
         
             
              rescue LoadError
         
     | 
| 
       46 
46 
     | 
    
         
             
                begin
         
     | 
| 
       47 
47 
     | 
    
         
             
                  require 'active_support/multibyte/chars'
         
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
       49 
49 
     | 
    
         
             
                  # Use ActiveSupport's normalizer
         
     | 
| 
       50 
50 
     | 
    
         
             
                  module LaTeX
         
     | 
| 
       51 
51 
     | 
    
         
             
                    def self.normalize_C(string)
         
     | 
| 
         @@ -73,7 +73,7 @@ module LaTeX 
     | 
|
| 
       73 
73 
     | 
    
         
             
              rescue LoadError
         
     | 
| 
       74 
74 
     | 
    
         
             
                begin
         
     | 
| 
       75 
75 
     | 
    
         
             
                  require 'math_ml'
         
     | 
| 
       76 
     | 
    
         
            -
             
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
       77 
77 
     | 
    
         
             
                  def self.to_math_ml(string)
         
     | 
| 
       78 
78 
     | 
    
         
             
                    MathML::String.mathml_latex_parser.parse(string, false)
         
     | 
| 
       79 
79 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -0,0 +1,61 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # -*- coding: utf-8 -*-
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module LaTeX
         
     | 
| 
      
 4 
     | 
    
         
            +
              module Decode
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
                class Greek < Decoder
         
     | 
| 
      
 7 
     | 
    
         
            +
                  @map = Hash[*%w{
         
     | 
| 
      
 8 
     | 
    
         
            +
                    alpha      α
         
     | 
| 
      
 9 
     | 
    
         
            +
                    beta       β
         
     | 
| 
      
 10 
     | 
    
         
            +
                    gamma      γ
         
     | 
| 
      
 11 
     | 
    
         
            +
                    delta      δ
         
     | 
| 
      
 12 
     | 
    
         
            +
                    epsilon    ε
         
     | 
| 
      
 13 
     | 
    
         
            +
                    zeta       ζ
         
     | 
| 
      
 14 
     | 
    
         
            +
                    eta        η
         
     | 
| 
      
 15 
     | 
    
         
            +
                    theta      θ
         
     | 
| 
      
 16 
     | 
    
         
            +
                    iota       ι
         
     | 
| 
      
 17 
     | 
    
         
            +
                    kappa      κ
         
     | 
| 
      
 18 
     | 
    
         
            +
                    lambda     λ
         
     | 
| 
      
 19 
     | 
    
         
            +
                    mu         μ
         
     | 
| 
      
 20 
     | 
    
         
            +
                    nu         ν
         
     | 
| 
      
 21 
     | 
    
         
            +
                    xi         ξ
         
     | 
| 
      
 22 
     | 
    
         
            +
                    rho        ρ
         
     | 
| 
      
 23 
     | 
    
         
            +
                    sigma      σ
         
     | 
| 
      
 24 
     | 
    
         
            +
                    tau        τ
         
     | 
| 
      
 25 
     | 
    
         
            +
                    upsilon    υ
         
     | 
| 
      
 26 
     | 
    
         
            +
                    phi        φ
         
     | 
| 
      
 27 
     | 
    
         
            +
                    chi        χ
         
     | 
| 
      
 28 
     | 
    
         
            +
                    psi        ψ
         
     | 
| 
      
 29 
     | 
    
         
            +
                    omega      ω
         
     | 
| 
      
 30 
     | 
    
         
            +
                    Alpha      Α
         
     | 
| 
      
 31 
     | 
    
         
            +
                    Beta       Β
         
     | 
| 
      
 32 
     | 
    
         
            +
                    Gamma      Γ
         
     | 
| 
      
 33 
     | 
    
         
            +
                    Delta      Δ
         
     | 
| 
      
 34 
     | 
    
         
            +
                    Epsilon    Ε
         
     | 
| 
      
 35 
     | 
    
         
            +
                    Zeta       Ζ
         
     | 
| 
      
 36 
     | 
    
         
            +
                    Eta        Η
         
     | 
| 
      
 37 
     | 
    
         
            +
                    Theta      Θ
         
     | 
| 
      
 38 
     | 
    
         
            +
                    Iota       Ι
         
     | 
| 
      
 39 
     | 
    
         
            +
                    Kappa      Κ
         
     | 
| 
      
 40 
     | 
    
         
            +
                    Lambda     Λ
         
     | 
| 
      
 41 
     | 
    
         
            +
                    Mu         Μ
         
     | 
| 
      
 42 
     | 
    
         
            +
                    Nu         Ν
         
     | 
| 
      
 43 
     | 
    
         
            +
                    Xi         Ξ
         
     | 
| 
      
 44 
     | 
    
         
            +
                    Rho        Ρ
         
     | 
| 
      
 45 
     | 
    
         
            +
                    Sigma      Σ
         
     | 
| 
      
 46 
     | 
    
         
            +
                    Tau        Τ
         
     | 
| 
      
 47 
     | 
    
         
            +
                    Upsilon    Υ
         
     | 
| 
      
 48 
     | 
    
         
            +
                    Phi        Φ
         
     | 
| 
      
 49 
     | 
    
         
            +
                    Chi        Χ
         
     | 
| 
      
 50 
     | 
    
         
            +
                    Psi        Ψ
         
     | 
| 
      
 51 
     | 
    
         
            +
                    Omega      Ω
         
     | 
| 
      
 52 
     | 
    
         
            +
                  }].freeze
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
                  @patterns = [
         
     | 
| 
      
 55 
     | 
    
         
            +
                    /\\(#{ map.keys.map { |k| Regexp.escape(k) }.join('|') })(?:\{\}|\s+|\b)/ou
         
     | 
| 
      
 56 
     | 
    
         
            +
                  ].freeze
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
                end
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
              end
         
     | 
| 
      
 61 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/latex/decode/maths.rb
    CHANGED
    
    | 
         @@ -1,11 +1,11 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module LaTeX
         
     | 
| 
       2 
2 
     | 
    
         
             
              module Decode
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
       4 
4 
     | 
    
         
             
                class Maths < Decoder
         
     | 
| 
       5 
5 
     | 
    
         
             
                  @patterns = [
         
     | 
| 
       6 
6 
     | 
    
         
             
                    /\$([^\$]+)\$/
         
     | 
| 
       7 
7 
     | 
    
         
             
                  ].freeze
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
       9 
9 
     | 
    
         
             
                  def self.decode! (string)
         
     | 
| 
       10 
10 
     | 
    
         
             
                    patterns.each do |pattern|
         
     | 
| 
       11 
11 
     | 
    
         
             
                      string.gsub!(pattern) do
         
     | 
| 
         @@ -18,4 +18,4 @@ module LaTeX 
     | 
|
| 
       18 
18 
     | 
    
         
             
                end
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
       20 
20 
     | 
    
         
             
              end
         
     | 
| 
       21 
     | 
    
         
            -
            end
         
     | 
| 
      
 21 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -2,9 +2,9 @@ 
     | 
|
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            module LaTeX
         
     | 
| 
       4 
4 
     | 
    
         
             
              module Decode
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
       6 
6 
     | 
    
         
             
                class Punctuation < Decoder
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
       8 
8 
     | 
    
         
             
                  @macros = Hash[*%w{
         
     | 
| 
       9 
9 
     | 
    
         
             
                    textendash         –
         
     | 
| 
       10 
10 
     | 
    
         
             
                    textemdash         —
         
     | 
| 
         @@ -43,15 +43,16 @@ module LaTeX 
     | 
|
| 
       43 
43 
     | 
    
         
             
                  ]].freeze
         
     | 
| 
       44 
44 
     | 
    
         | 
| 
       45 
45 
     | 
    
         
             
                  @map = @macros.merge(@symbols).freeze
         
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
       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 
53 
     | 
    
         
             
                  ].freeze
         
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
       54 
55 
     | 
    
         
             
                end
         
     | 
| 
       55 
56 
     | 
    
         | 
| 
       56 
57 
     | 
    
         
             
              end
         
     | 
| 
       57 
     | 
    
         
            -
            end
         
     | 
| 
      
 58 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/latex/decode/symbols.rb
    CHANGED
    
    | 
         @@ -2,7 +2,7 @@ 
     | 
|
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            module LaTeX
         
     | 
| 
       4 
4 
     | 
    
         
             
              module Decode
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
       6 
6 
     | 
    
         
             
                class Symbols < Decoder
         
     | 
| 
       7 
7 
     | 
    
         
             
                  @map = Hash[*%w{
         
     | 
| 
       8 
8 
     | 
    
         
             
                    textcolonmonetary ₡
         
     | 
| 
         @@ -216,8 +216,8 @@ module LaTeX 
     | 
|
| 
       216 
216 
     | 
    
         
             
                  @patterns = [
         
     | 
| 
       217 
217 
     | 
    
         
             
                    /\\(#{ map.keys.map { |k| Regexp.escape(k) }.join('|') })(?:\{\}|\s+|\b)/ou
         
     | 
| 
       218 
218 
     | 
    
         
             
                  ].freeze
         
     | 
| 
       219 
     | 
    
         
            -
             
     | 
| 
      
 219 
     | 
    
         
            +
             
     | 
| 
       220 
220 
     | 
    
         
             
                end
         
     | 
| 
       221 
221 
     | 
    
         | 
| 
       222 
222 
     | 
    
         
             
              end
         
     | 
| 
       223 
     | 
    
         
            -
            end
         
     | 
| 
      
 223 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/latex/decode/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,27 +1,27 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: latex-decode
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.2.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Sylvester Keil
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2015-02-02 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: unicode
         
     | 
| 
       15 
15 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       16 
16 
     | 
    
         
             
                requirements:
         
     | 
| 
       17 
     | 
    
         
            -
                - - ~>
         
     | 
| 
      
 17 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
       18 
18 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       19 
19 
     | 
    
         
             
                    version: '0.4'
         
     | 
| 
       20 
20 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       21 
21 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       22 
22 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       23 
23 
     | 
    
         
             
                requirements:
         
     | 
| 
       24 
     | 
    
         
            -
                - - ~>
         
     | 
| 
      
 24 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
       25 
25 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       26 
26 
     | 
    
         
             
                    version: '0.4'
         
     | 
| 
       27 
27 
     | 
    
         
             
            description: Decodes strings formatted in LaTeX to equivalent Unicode strings.
         
     | 
| 
         @@ -33,8 +33,8 @@ extra_rdoc_files: 
     | 
|
| 
       33 
33 
     | 
    
         
             
            - README.md
         
     | 
| 
       34 
34 
     | 
    
         
             
            - LICENSE
         
     | 
| 
       35 
35 
     | 
    
         
             
            files:
         
     | 
| 
       36 
     | 
    
         
            -
            - .gitignore
         
     | 
| 
       37 
     | 
    
         
            -
            - .travis.yml
         
     | 
| 
      
 36 
     | 
    
         
            +
            - ".gitignore"
         
     | 
| 
      
 37 
     | 
    
         
            +
            - ".travis.yml"
         
     | 
| 
       38 
38 
     | 
    
         
             
            - Gemfile
         
     | 
| 
       39 
39 
     | 
    
         
             
            - LICENSE
         
     | 
| 
       40 
40 
     | 
    
         
             
            - README.md
         
     | 
| 
         @@ -42,6 +42,7 @@ files: 
     | 
|
| 
       42 
42 
     | 
    
         
             
            - cucumber.yml
         
     | 
| 
       43 
43 
     | 
    
         
             
            - features/brackets.feature
         
     | 
| 
       44 
44 
     | 
    
         
             
            - features/diacritics.feature
         
     | 
| 
      
 45 
     | 
    
         
            +
            - features/greek.feature
         
     | 
| 
       45 
46 
     | 
    
         
             
            - features/maths.feature
         
     | 
| 
       46 
47 
     | 
    
         
             
            - features/non-latex.feature
         
     | 
| 
       47 
48 
     | 
    
         
             
            - features/punctuation.feature
         
     | 
| 
         @@ -55,6 +56,7 @@ files: 
     | 
|
| 
       55 
56 
     | 
    
         
             
            - lib/latex/decode/base.rb
         
     | 
| 
       56 
57 
     | 
    
         
             
            - lib/latex/decode/compatibility.rb
         
     | 
| 
       57 
58 
     | 
    
         
             
            - lib/latex/decode/diacritics.rb
         
     | 
| 
      
 59 
     | 
    
         
            +
            - lib/latex/decode/greek.rb
         
     | 
| 
       58 
60 
     | 
    
         
             
            - lib/latex/decode/maths.rb
         
     | 
| 
       59 
61 
     | 
    
         
             
            - lib/latex/decode/punctuation.rb
         
     | 
| 
       60 
62 
     | 
    
         
             
            - lib/latex/decode/symbols.rb
         
     | 
| 
         @@ -65,34 +67,35 @@ licenses: 
     | 
|
| 
       65 
67 
     | 
    
         
             
            metadata: {}
         
     | 
| 
       66 
68 
     | 
    
         
             
            post_install_message: 
         
     | 
| 
       67 
69 
     | 
    
         
             
            rdoc_options:
         
     | 
| 
       68 
     | 
    
         
            -
            - --line-numbers
         
     | 
| 
       69 
     | 
    
         
            -
            - --inline-source
         
     | 
| 
       70 
     | 
    
         
            -
            - --title
         
     | 
| 
       71 
     | 
    
         
            -
            -  
     | 
| 
       72 
     | 
    
         
            -
            - --main
         
     | 
| 
      
 70 
     | 
    
         
            +
            - "--line-numbers"
         
     | 
| 
      
 71 
     | 
    
         
            +
            - "--inline-source"
         
     | 
| 
      
 72 
     | 
    
         
            +
            - "--title"
         
     | 
| 
      
 73 
     | 
    
         
            +
            - '"LaTeX-Decode Documentation"'
         
     | 
| 
      
 74 
     | 
    
         
            +
            - "--main"
         
     | 
| 
       73 
75 
     | 
    
         
             
            - README.md
         
     | 
| 
       74 
     | 
    
         
            -
            - --webcvs=http://github.com/inukshuk/latex-decode/tree/master/
         
     | 
| 
      
 76 
     | 
    
         
            +
            - "--webcvs=http://github.com/inukshuk/latex-decode/tree/master/"
         
     | 
| 
       75 
77 
     | 
    
         
             
            require_paths:
         
     | 
| 
       76 
78 
     | 
    
         
             
            - lib
         
     | 
| 
       77 
79 
     | 
    
         
             
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
       78 
80 
     | 
    
         
             
              requirements:
         
     | 
| 
       79 
     | 
    
         
            -
              - -  
     | 
| 
      
 81 
     | 
    
         
            +
              - - ">="
         
     | 
| 
       80 
82 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       81 
83 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       82 
84 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
       83 
85 
     | 
    
         
             
              requirements:
         
     | 
| 
       84 
     | 
    
         
            -
              - -  
     | 
| 
      
 86 
     | 
    
         
            +
              - - ">="
         
     | 
| 
       85 
87 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       86 
88 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       87 
89 
     | 
    
         
             
            requirements: []
         
     | 
| 
       88 
90 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       89 
     | 
    
         
            -
            rubygems_version: 2. 
     | 
| 
      
 91 
     | 
    
         
            +
            rubygems_version: 2.4.5
         
     | 
| 
       90 
92 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       91 
93 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       92 
94 
     | 
    
         
             
            summary: Decodes LaTeX to Unicode.
         
     | 
| 
       93 
95 
     | 
    
         
             
            test_files:
         
     | 
| 
       94 
96 
     | 
    
         
             
            - features/brackets.feature
         
     | 
| 
       95 
97 
     | 
    
         
             
            - features/diacritics.feature
         
     | 
| 
      
 98 
     | 
    
         
            +
            - features/greek.feature
         
     | 
| 
       96 
99 
     | 
    
         
             
            - features/maths.feature
         
     | 
| 
       97 
100 
     | 
    
         
             
            - features/non-latex.feature
         
     | 
| 
       98 
101 
     | 
    
         
             
            - features/punctuation.feature
         
     |