latex-decode 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/features/punctuation.feature +8 -6
- data/features/symbols.feature +21 -0
- data/lib/latex/decode/base.rb +6 -3
- data/lib/latex/decode/symbols.rb +4 -2
- data/lib/latex/decode/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b72cef2bcae3250f385227cc6280b46453f9a8a9
|
4
|
+
data.tar.gz: 594fa9c2ccf9ae5b29935813d850459981679d4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc225084cca699158fb8ecaa31770d01da0c9fdef2fbf85a15e79d314f06a6515fed8a8a0ff7e1c3502bbb950693fb2672d8d7447eeed102c4d3459c3f0561ea
|
7
|
+
data.tar.gz: 534f83cba6ca70064c95c41a249a2bc389f39a8e5507ff4def143a34bc8fa3b239f109975ddeca10d7b0a085b5dcf593b09695db602514dc03a4e916a0c48e1f
|
@@ -33,12 +33,14 @@ Feature: Decode LaTeX punctuation directives
|
|
33
33
|
|
34
34
|
|
35
35
|
Scenarios: Punctuation symbols
|
36
|
-
| latex
|
37
|
-
| -
|
38
|
-
| --
|
39
|
-
| ---
|
40
|
-
| \\~{}
|
41
|
-
|
|
36
|
+
| latex | unicode | description |
|
37
|
+
| - | - | hyphen |
|
38
|
+
| -- | – | en-dash |
|
39
|
+
| --- | — | em-dash |
|
40
|
+
| \\~{} | ~ | tilde |
|
41
|
+
| \\textasciitilde{} | ~ | tilde |
|
42
|
+
| \\textasciitilde | ~ | tilde |
|
43
|
+
| X\\ X | X X | space |
|
42
44
|
|
43
45
|
Scenarios: Quotation marks
|
44
46
|
| latex | unicode | description |
|
@@ -0,0 +1,21 @@
|
|
1
|
+
Feature: Decode LaTeX symbol directives
|
2
|
+
As a hacker who works with LaTeX
|
3
|
+
I want to be able to decode LaTeX symbol directives
|
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: Arrows
|
10
|
+
| latex | unicode |
|
11
|
+
| \\leftarrow | ← |
|
12
|
+
| \\uparrow | ↑ |
|
13
|
+
| \\downarrow | ↓ |
|
14
|
+
| \\rightarrow | → |
|
15
|
+
|
16
|
+
Scenarios: Whitespace
|
17
|
+
| latex | unicode | description |
|
18
|
+
| x\\,x | x x | small space |
|
19
|
+
| x~x | x x | non-breaking space |
|
20
|
+
| ~x | x | non-breaking space |
|
21
|
+
|
data/lib/latex/decode/base.rb
CHANGED
@@ -35,15 +35,18 @@ module LaTeX
|
|
35
35
|
def normalize (string)
|
36
36
|
string.gsub!(/\\(?:i|j)\b/) { |m| m == '\\i' ? 'ı' : 'ȷ' }
|
37
37
|
|
38
|
-
|
38
|
+
# \foo\ bar -> \foo{} bar
|
39
39
|
string.gsub!(/(\\[a-zA-Z]+)\\(\s+)/, '\1{}\2')
|
40
40
|
|
41
|
-
|
41
|
+
# Aaaa\o, -> Aaaa\o{},
|
42
42
|
string.gsub!(/([^{]\\\w)([;,.:%])/, '\1{}\2')
|
43
43
|
|
44
|
-
|
44
|
+
# \c cb -> \c{cb}
|
45
45
|
string.gsub!(/(\\[^\sij&#\$\{\}_~%])\s+([[:alpha:]]+)\b/i, '\1{\2}')
|
46
46
|
|
47
|
+
# non-breaking spaces
|
48
|
+
string.gsub!(/(\A|[^\\])~/, LaTeX.to_unicode("\\1\u00a0"))
|
49
|
+
|
47
50
|
string
|
48
51
|
end
|
49
52
|
|
data/lib/latex/decode/symbols.rb
CHANGED
@@ -4,7 +4,8 @@ module LaTeX
|
|
4
4
|
module Decode
|
5
5
|
|
6
6
|
class Symbols < Decoder
|
7
|
-
|
7
|
+
|
8
|
+
@map = Hash[*%W{
|
8
9
|
textcolonmonetary ₡
|
9
10
|
textlira ₤
|
10
11
|
textnaira ₦
|
@@ -211,7 +212,8 @@ module LaTeX
|
|
211
212
|
tone1 ˩
|
212
213
|
ss ß
|
213
214
|
, \u2009
|
214
|
-
}].freeze
|
215
|
+
}.map { |s| LaTeX.to_unicode(s) }].freeze
|
216
|
+
|
215
217
|
|
216
218
|
@patterns = [
|
217
219
|
/\\(#{ map.keys.map { |k| Regexp.escape(k) }.join('|') })(?:\{\}|\s+|\b)/ou
|
data/lib/latex/decode/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: latex-decode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sylvester Keil
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03
|
11
|
+
date: 2015-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unicode
|
@@ -49,6 +49,7 @@ files:
|
|
49
49
|
- features/special_characters.feature
|
50
50
|
- features/step_definitions/latex.rb
|
51
51
|
- features/support/env.rb
|
52
|
+
- features/symbols.feature
|
52
53
|
- features/umlauts.feature
|
53
54
|
- latex-decode.gemspec
|
54
55
|
- lib/latex/decode.rb
|
@@ -102,5 +103,6 @@ test_files:
|
|
102
103
|
- features/special_characters.feature
|
103
104
|
- features/step_definitions/latex.rb
|
104
105
|
- features/support/env.rb
|
106
|
+
- features/symbols.feature
|
105
107
|
- features/umlauts.feature
|
106
108
|
has_rdoc:
|