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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ab76545e91f882f2219178cfed05479ff8863c41
4
- data.tar.gz: 14deebe77e665682d8e6ac4185136b0944643649
3
+ metadata.gz: b72cef2bcae3250f385227cc6280b46453f9a8a9
4
+ data.tar.gz: 594fa9c2ccf9ae5b29935813d850459981679d4f
5
5
  SHA512:
6
- metadata.gz: 13508082cf84fe12b62fac4ccf1faee0becb2b0f2ffe5d0836f3fc43c55293ba97f8d8d4ef630f083d5e84b30fd4bf61f47014d79b2d134a6940ca8859b962b3
7
- data.tar.gz: e6712e11c0ea93d8e92edcb6bbfdf10295ce9171b68337919cab04d275f04f13277bdc56cb9e562c1f7f146d5c6ad54114d97e74b9fd86b1c39903000968bad2
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 | unicode | description |
37
- | - | - | hyphen |
38
- | -- | – | en-dash |
39
- | --- | — | em-dash |
40
- | \\~{} | ~ | tilde |
41
- | X\\ X | X X | space |
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
+
@@ -35,15 +35,18 @@ module LaTeX
35
35
  def normalize (string)
36
36
  string.gsub!(/\\(?:i|j)\b/) { |m| m == '\\i' ? 'ı' : 'ȷ' }
37
37
 
38
- # \foo\ bar -> \foo{} bar
38
+ # \foo\ bar -> \foo{} bar
39
39
  string.gsub!(/(\\[a-zA-Z]+)\\(\s+)/, '\1{}\2')
40
40
 
41
- # Aaaa\o, -> Aaaa\o{},
41
+ # Aaaa\o, -> Aaaa\o{},
42
42
  string.gsub!(/([^{]\\\w)([;,.:%])/, '\1{}\2')
43
43
 
44
- # \c cb -> \c{cb}
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
 
@@ -4,7 +4,8 @@ module LaTeX
4
4
  module Decode
5
5
 
6
6
  class Symbols < Decoder
7
- @map = Hash[*%w{
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
@@ -1,5 +1,5 @@
1
1
  module LaTeX
2
2
  module Decode
3
- VERSION = '0.2.1'.freeze
3
+ VERSION = '0.2.2'.freeze
4
4
  end
5
5
  end
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.1
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-25 00:00:00.000000000 Z
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: