typogrowth 0.9.0 → 0.9.1

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
  !binary "U0hBMQ==":
3
- metadata.gz: 8b9cc2df68d09b41d6e66c2f23267d983b3de918
4
- data.tar.gz: e941117481606671b6f2761e587d2f52d7ed7561
3
+ metadata.gz: 8e2f320681c171005dd2e3b76459c3fbf4ae1046
4
+ data.tar.gz: c8fc540e85c5f9117865753bfc253b3d6f1f7487
5
5
  !binary "U0hBNTEy":
6
- metadata.gz: 3a46dceca2914e0efb637b78f54d850e8426f860127aeb6d50da8f79b5c0a45a6c4ffd358632ad9578050513aa92b35cc2bee2429ad34b1b9540d6f86f39b9b3
7
- data.tar.gz: 23d646481747e78b23e29ae2360854aeb3b3849a773f535d5426dae39f94c85ce81cb392a024cae8f9bbd9d90f7ca40e16d2ce0af765687e1349f2df65a85cd0
6
+ metadata.gz: 84020ddf3dc6e4ca88fbb3533f64f20c19baa9fc6bc4fe7ccbc75b2959ecef1cf6e7c869e09fe404770a63e18ed06962cb7e325b6d0837dd6635b17c1104b5ed
7
+ data.tar.gz: 8617b80ae6d37ea526a18a899d62e98db4d37e699d7835f473b850430dbc9561e345fd1a3384b22b3dafe1d11537a404bc128db664ea43f43e847fef7c76fefa
data/.gitignore CHANGED
@@ -16,3 +16,4 @@ test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
18
  /nbproject/
19
+ *.komodoproject
data/README.md CHANGED
@@ -34,22 +34,22 @@ Or install it yourself as:
34
34
  ## Usage
35
35
 
36
36
  ```ruby
37
- s = 'And God said "Baz heard "Bar" once" , and there was light.'
38
- puts s.typo
39
- # ⇒ And God said “Baz heard ‘Bar’ once,” and there was light.
40
- puts Typogrowth.parse(s)
41
- # ⇒ And God said “Baz heard ‘Bar’ once,” and there was light.
42
-
43
- s = 'И Бог сказал: "Я - слышу "Бум" и "Бам" где-то там" , и стало светло.'
44
- puts s.typo('ru') # Explicit locale specification may be omitted
45
- # while running under ru_RU.UTF-8 locale
46
- # ⇒ И Бог сказал: «Я — слышу „Бум“ и „Бам“ где-то там», и стало светло.
47
-
48
- s = 'And God said "Oslo coordinates are: 59°57′N 10°45′E" and there was light.'
49
- s.typo!
50
- # ⇒ And God said “Oslo coordinates are: 59°57′N 10°45′E” and there was light.
51
- puts s
52
- # ⇒ And God said “Oslo coordinates are: 59°57′N 10°45′E” and there was light.
37
+ s = 'And God said "Baz heard "Bar" once" , and there was light.'
38
+ puts s.typo
39
+ # ⇒ And God said “Baz heard ‘Bar’ once,” and there was light.
40
+ puts Typogrowth.parse(s)
41
+ # ⇒ And God said “Baz heard ‘Bar’ once,” and there was light.
42
+
43
+ s = 'И Бог сказал: "Я - слышу "Бум" и "Бам" где-то там" , и стало светло.'
44
+ puts s.typo('ru') # Explicit locale specification may be omitted
45
+ # while running under ru_RU.UTF-8 locale
46
+ # ⇒ И Бог сказал: «Я — слышу „Бум“ и „Бам“ где-то там», и стало светло.
47
+
48
+ s = 'And God said "Oslo coordinates are: 59°57′N 10°45′E" and there was light.'
49
+ s.typo!
50
+ # ⇒ And God said “Oslo coordinates are: 59°57′N 10°45′E” and there was light.
51
+ puts s
52
+ # ⇒ And God said “Oslo coordinates are: 59°57′N 10°45′E” and there was light.
53
53
  ```
54
54
 
55
55
  ## Contributing
@@ -14,7 +14,7 @@ Feature: Text is to be typographed (spacing and pubctuation are to be sanitized)
14
14
  | "And God said \"I--heard \"Booh \"Bah\" Booh\" and \"Bam\" in heaven\" and there was light." | "And God said “I—heard ‘Booh “Bah” Booh’ and ‘Bam’ in heaven” and there was light." |
15
15
  | "And God said \"I - heard \"Booh Bah Booh\" and \"Bam\" in heaven\" and there was light." | "And God said “I—heard ‘Booh Bah Booh’ and ‘Bam’ in heaven” and there was light." |
16
16
  | "And God said \"Oslo coordinates are: 59°57′N 10°45′E\" and there was light." | "And God said “Oslo coordinates are: 59°57′N 10°45′E” and there was light." |
17
- | "And God said \"That's a 6.3\" man, he sees sunsets at 10°20'30\" E.\" and there was light." | "And God said “That’s a 6.3″ man, he sees sunsets at 10°20′30″ E.” and there was light." |
17
+ | "And God said \"That's a 6.3\" man, he sees sunsets at 10°20'30\" E.\" and there was light." | "And God said “That’s a 6.3″ man, he sees sunsets at 10°20′30″ E.” and there was light." |
18
18
  | "And God said \"Foo\" , and there was light." | "And God said “Foo,” and there was light." |
19
19
  | "And God said \"Baz heard 'Foos' Bar' once\" , and there was light." | "And God said “Baz heard ‘Foos’ Bar’ once,” and there was light." |
20
20
  | "And God, loving ellipsis, said.... And..." | "And God, loving ellipsis, said… And…" |
@@ -28,8 +28,8 @@ Feature: Text is to be typographed (spacing and pubctuation are to be sanitized)
28
28
 
29
29
  Examples:
30
30
  | input | output |
31
- | "И Бог сказал: \"Я - слышу \"Бум\" и \"Бам\" где-то там\" , и стало светло." | "И Бог сказал: «Я — слышу „Бум“ и „Бам“ где-то там», и стало светло." |
32
- | "И Бог сказал: \"Я - слышу \"Бум \"и\" Бам\" где-то там\" , и стало светло." | "И Бог сказал: «Я — слышу „Бум «и» Бам“ где-то там», и стало светло." |
31
+ | "И Бог сказал: \"Я - слышу \"Бум\" и \"Бам\" где-то там\" , и стало светло." | "И Бог сказал: «Я — слышу „Бум“ и „Бам“ где-то там», и стало светло." |
32
+ | "И Бог сказал: \"Я - слышу \"Бум \"и\" Бам\" где-то там\" , и стало светло." | "И Бог сказал: «Я — слышу „Бум «и» Бам“ где-то там», и стало светло." |
33
33
  | "Строка со ссылкой: http://wikipedia.org (ссылка)." | "Строка со ссылкой: http://wikipedia.org (ссылка)." |
34
34
 
35
35
  Scenario Outline: Spacing before/after punctuation
@@ -52,3 +52,14 @@ Feature: Text is to be typographed (spacing and pubctuation are to be sanitized)
52
52
  Given the input string is "Foo 'Bar' Baz"
53
53
  When input string is modified inplace with typo!
54
54
  Then typoed result should equal to "Foo “Bar” Baz"
55
+
56
+ Scenario Outline: Orphans handling
57
+ Given the input string is <input>
58
+ When input string is processed with Typogrowl’s typography parser
59
+ Then the typoed result should equal to <output>
60
+ And the call to string’s typo should equal to <output>
61
+
62
+ Examples:
63
+ | input | output |
64
+ | "This is a cat." | "This is a cat." |
65
+
@@ -115,11 +115,11 @@
115
115
 
116
116
  :punctuation :
117
117
  :opening_orphan :
118
- :re : '([(¿¡§#№]|\p{Sc})(?:\s)*'
118
+ :re : '([(¿¡§#№]|\p{Sc})(?:\s+)'
119
119
  :default :
120
120
  - '\1'
121
121
  :closing_orphan :
122
- :re : '(?:\s)*([.,:;!?)])'
122
+ :re : '(?:\s+)([.,:;!?)])'
123
123
  :default :
124
124
  - '\1'
125
125
  :closing_clamped :
@@ -129,4 +129,14 @@
129
129
  :fixup :
130
130
  :re : '([!?.]+)(?:\s*)(\.+)'
131
131
  :default :
132
- - '\1\2'
132
+ - '\1\2'
133
+
134
+ :orphans :
135
+ :dangling_right :
136
+ :re : '(?<=\s|\A)(\p{L})\s+'
137
+ :default :
138
+ - '\1 '
139
+ :dangling_left :
140
+ :re : '\s+(p{Punct})(?=\s|\Z)'
141
+ :default :
142
+ - ' \1'
@@ -1,3 +1,3 @@
1
1
  module Typogrowth
2
- VERSION = "0.9.0"
2
+ VERSION = "0.9.1"
3
3
  end
data/lib/typogrowth.rb CHANGED
@@ -78,7 +78,7 @@ module Typogrowth
78
78
  lang = lang.to_sym
79
79
  str.split(/\R{2,}/).map { |para|
80
80
  para.gsub(URI.regexp) { |m| "⚓#{Base64.encode64 m}⚓" }
81
- instance.yaml.each { |k, values|
81
+ instance.yaml.each { |key, values|
82
82
  values.each { |k, v|
83
83
  if !!v[:re]
84
84
  v[lang] = v[:default] if (!v[lang] || v[lang].size.zero?)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typogrowth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexei Matyushkin