latex-decode 0.1.1-java → 0.2.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- 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 +20 -21
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 78fb9f88b5a323057e430d58dc3abb02cfd9e775
|
4
|
+
data.tar.gz: 38c71cb52118ddf38e67925a39d0af170c9195f3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2bf9aa83f8f59886fa311ce259a9862b3ac9755f71b9a31e41196929544eb12a5b3c321be2edbf4582c043e364df37782dc21f417f21bc78b794dc5d5e1a2cd7
|
7
|
+
data.tar.gz: b7b59e9a3ac52cbacc8189d8cdeb076b7cbb7500e3309fd473c3d6988c753802b8bb57e23e67ba00c3f84aa62f8cc8a0f2d0527e6573885910c4141ded938574
|
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,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: latex-decode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.2.0
|
6
5
|
platform: java
|
7
6
|
authors:
|
8
7
|
- Sylvester Keil
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2015-02-02 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
13
|
description: Decodes strings formatted in LaTeX to equivalent Unicode strings.
|
15
14
|
email:
|
@@ -20,8 +19,8 @@ extra_rdoc_files:
|
|
20
19
|
- README.md
|
21
20
|
- LICENSE
|
22
21
|
files:
|
23
|
-
-
|
24
|
-
-
|
22
|
+
- .gitignore
|
23
|
+
- .travis.yml
|
25
24
|
- Gemfile
|
26
25
|
- LICENSE
|
27
26
|
- README.md
|
@@ -29,6 +28,7 @@ files:
|
|
29
28
|
- cucumber.yml
|
30
29
|
- features/brackets.feature
|
31
30
|
- features/diacritics.feature
|
31
|
+
- features/greek.feature
|
32
32
|
- features/maths.feature
|
33
33
|
- features/non-latex.feature
|
34
34
|
- features/punctuation.feature
|
@@ -42,6 +42,7 @@ files:
|
|
42
42
|
- lib/latex/decode/base.rb
|
43
43
|
- lib/latex/decode/compatibility.rb
|
44
44
|
- lib/latex/decode/diacritics.rb
|
45
|
+
- lib/latex/decode/greek.rb
|
45
46
|
- lib/latex/decode/maths.rb
|
46
47
|
- lib/latex/decode/punctuation.rb
|
47
48
|
- lib/latex/decode/symbols.rb
|
@@ -49,40 +50,38 @@ files:
|
|
49
50
|
homepage: http://github.com/inukshuk/latex-decode
|
50
51
|
licenses:
|
51
52
|
- GPL-3
|
53
|
+
metadata: {}
|
52
54
|
post_install_message:
|
53
55
|
rdoc_options:
|
54
|
-
-
|
55
|
-
-
|
56
|
-
-
|
57
|
-
- "
|
58
|
-
-
|
56
|
+
- --line-numbers
|
57
|
+
- --inline-source
|
58
|
+
- --title
|
59
|
+
- '"LaTeX-Decode Documentation"'
|
60
|
+
- --main
|
59
61
|
- README.md
|
60
|
-
-
|
62
|
+
- --webcvs=http://github.com/inukshuk/latex-decode/tree/master/
|
61
63
|
require_paths:
|
62
64
|
- lib
|
63
65
|
required_ruby_version: !ruby/object:Gem::Requirement
|
64
66
|
requirements:
|
65
|
-
- -
|
67
|
+
- - '>='
|
66
68
|
- !ruby/object:Gem::Version
|
67
|
-
version:
|
68
|
-
MA==
|
69
|
-
none: false
|
69
|
+
version: '0'
|
70
70
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
|
-
- -
|
72
|
+
- - '>='
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version:
|
75
|
-
MA==
|
76
|
-
none: false
|
74
|
+
version: '0'
|
77
75
|
requirements: []
|
78
76
|
rubyforge_project:
|
79
|
-
rubygems_version: 1.
|
77
|
+
rubygems_version: 2.1.9
|
80
78
|
signing_key:
|
81
|
-
specification_version:
|
79
|
+
specification_version: 4
|
82
80
|
summary: Decodes LaTeX to Unicode.
|
83
81
|
test_files:
|
84
82
|
- features/brackets.feature
|
85
83
|
- features/diacritics.feature
|
84
|
+
- features/greek.feature
|
86
85
|
- features/maths.feature
|
87
86
|
- features/non-latex.feature
|
88
87
|
- features/punctuation.feature
|