latex-decode 0.1.0-java → 0.1.1-java
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.
- data/.travis.yml +2 -5
- data/Gemfile +10 -4
- data/features/maths.feature +9 -0
- data/features/non-latex.feature +1 -1
- data/features/special_characters.feature +1 -0
- data/features/support/env.rb +7 -1
- data/latex-decode.gemspec +0 -4
- data/lib/latex/decode.rb +12 -9
- data/lib/latex/decode/base.rb +0 -1
- data/lib/latex/decode/compatibility.rb +37 -9
- data/lib/latex/decode/maths.rb +21 -0
- data/lib/latex/decode/punctuation.rb +1 -1
- data/lib/latex/decode/version.rb +1 -1
- metadata +6 -51
data/.travis.yml
CHANGED
@@ -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 :
|
5
|
-
|
6
|
-
|
4
|
+
group :test do
|
5
|
+
gem 'rake'
|
6
|
+
gem 'rspec', '~> 2.13'
|
7
|
+
gem 'cucumber', '~> 1.2'
|
7
8
|
end
|
8
9
|
|
9
|
-
|
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'
|
@@ -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 ''
|
data/features/non-latex.feature
CHANGED
data/features/support/env.rb
CHANGED
data/latex-decode.gemspec
CHANGED
@@ -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 = []
|
data/lib/latex/decode.rb
CHANGED
@@ -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
|
data/lib/latex/decode/base.rb
CHANGED
@@ -14,8 +14,8 @@ else
|
|
14
14
|
|
15
15
|
module LaTeX
|
16
16
|
def self.to_unicode(string)
|
17
|
-
|
18
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
data/lib/latex/decode/version.rb
CHANGED
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.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: java
|
7
7
|
authors:
|
@@ -9,56 +9,8 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
13
|
-
dependencies:
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
name: bundler
|
16
|
-
version_requirements: !ruby/object:Gem::Requirement
|
17
|
-
requirements:
|
18
|
-
- - "~>"
|
19
|
-
- !ruby/object:Gem::Version
|
20
|
-
version: '1.0'
|
21
|
-
none: false
|
22
|
-
requirement: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.0'
|
27
|
-
none: false
|
28
|
-
prerelease: false
|
29
|
-
type: :development
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
|
-
name: rspec
|
32
|
-
version_requirements: !ruby/object:Gem::Requirement
|
33
|
-
requirements:
|
34
|
-
- - "~>"
|
35
|
-
- !ruby/object:Gem::Version
|
36
|
-
version: '2.6'
|
37
|
-
none: false
|
38
|
-
requirement: !ruby/object:Gem::Requirement
|
39
|
-
requirements:
|
40
|
-
- - "~>"
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
version: '2.6'
|
43
|
-
none: false
|
44
|
-
prerelease: false
|
45
|
-
type: :development
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: cucumber
|
48
|
-
version_requirements: !ruby/object:Gem::Requirement
|
49
|
-
requirements:
|
50
|
-
- - "~>"
|
51
|
-
- !ruby/object:Gem::Version
|
52
|
-
version: '1.0'
|
53
|
-
none: false
|
54
|
-
requirement: !ruby/object:Gem::Requirement
|
55
|
-
requirements:
|
56
|
-
- - "~>"
|
57
|
-
- !ruby/object:Gem::Version
|
58
|
-
version: '1.0'
|
59
|
-
none: false
|
60
|
-
prerelease: false
|
61
|
-
type: :development
|
12
|
+
date: 2013-05-06 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
62
14
|
description: Decodes strings formatted in LaTeX to equivalent Unicode strings.
|
63
15
|
email:
|
64
16
|
- http://sylvester.keil.or.at
|
@@ -77,6 +29,7 @@ files:
|
|
77
29
|
- cucumber.yml
|
78
30
|
- features/brackets.feature
|
79
31
|
- features/diacritics.feature
|
32
|
+
- features/maths.feature
|
80
33
|
- features/non-latex.feature
|
81
34
|
- features/punctuation.feature
|
82
35
|
- features/special_characters.feature
|
@@ -89,6 +42,7 @@ files:
|
|
89
42
|
- lib/latex/decode/base.rb
|
90
43
|
- lib/latex/decode/compatibility.rb
|
91
44
|
- lib/latex/decode/diacritics.rb
|
45
|
+
- lib/latex/decode/maths.rb
|
92
46
|
- lib/latex/decode/punctuation.rb
|
93
47
|
- lib/latex/decode/symbols.rb
|
94
48
|
- lib/latex/decode/version.rb
|
@@ -129,6 +83,7 @@ summary: Decodes LaTeX to Unicode.
|
|
129
83
|
test_files:
|
130
84
|
- features/brackets.feature
|
131
85
|
- features/diacritics.feature
|
86
|
+
- features/maths.feature
|
132
87
|
- features/non-latex.feature
|
133
88
|
- features/punctuation.feature
|
134
89
|
- features/special_characters.feature
|