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 +4 -4
- data/.gitignore +1 -0
- data/README.md +16 -16
- data/features/typogrowth.feature +14 -3
- data/lib/config/typogrowth.yaml +13 -3
- data/lib/typogrowth/version.rb +1 -1
- data/lib/typogrowth.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e2f320681c171005dd2e3b76459c3fbf4ae1046
|
4
|
+
data.tar.gz: c8fc540e85c5f9117865753bfc253b3d6f1f7487
|
5
5
|
!binary "U0hBNTEy":
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84020ddf3dc6e4ca88fbb3533f64f20c19baa9fc6bc4fe7ccbc75b2959ecef1cf6e7c869e09fe404770a63e18ed06962cb7e325b6d0837dd6635b17c1104b5ed
|
7
|
+
data.tar.gz: 8617b80ae6d37ea526a18a899d62e98db4d37e699d7835f473b850430dbc9561e345fd1a3384b22b3dafe1d11537a404bc128db664ea43f43e847fef7c76fefa
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -34,22 +34,22 @@ Or install it yourself as:
|
|
34
34
|
## Usage
|
35
35
|
|
36
36
|
```ruby
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
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
|
data/features/typogrowth.feature
CHANGED
@@ -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
|
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
|
+
|
data/lib/config/typogrowth.yaml
CHANGED
@@ -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'
|
data/lib/typogrowth/version.rb
CHANGED
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 { |
|
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?)
|