typography 0.2.1 → 0.3.0
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/lib/typography/core.rb +2 -2
- data/lib/typography/version.rb +1 -1
- data/spec/typography_spec.rb +15 -15
- metadata +5 -5
data/lib/typography/core.rb
CHANGED
@@ -13,7 +13,7 @@ module TypographyHelper
|
|
13
13
|
@out.gsub!(/\“/,'„')
|
14
14
|
@out.gsub!(/\”/,'“')
|
15
15
|
#russian quotes
|
16
|
-
@out = replace_quotes '
|
16
|
+
@out = replace_quotes '«', '»', '„', '“', 'а-яА-Я'
|
17
17
|
|
18
18
|
#english quotes
|
19
19
|
@out = replace_quotes
|
@@ -47,7 +47,7 @@ module TypographyHelper
|
|
47
47
|
|
48
48
|
replace_quotes = lambda do
|
49
49
|
old_str = str.dup
|
50
|
-
str.gsub!(Regexp.new("(\"|\')([#{letters}].*?[^\\s])\\1", Regexp::MULTILINE | Regexp::IGNORECASE)) do |match|
|
50
|
+
str.gsub!(Regexp.new("(\"|\'|")([#{letters}].*?[^\\s])\\1", Regexp::MULTILINE | Regexp::IGNORECASE)) do |match|
|
51
51
|
inside, before, after = $2, $`, $'
|
52
52
|
if after.match(/^([^<]+>|>)/) || before.match(/<[^>]+$/) #inside tag
|
53
53
|
match
|
data/lib/typography/version.rb
CHANGED
data/spec/typography_spec.rb
CHANGED
@@ -21,20 +21,20 @@ describe TypographyHelper, 'with typography' do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should make russian quotes for quotes with first russian letter" do
|
24
|
-
ty('"текст"').should == '
|
25
|
-
ty('Text "текст" text').should == 'Text
|
26
|
-
ty('Text "текст" text "Другой текст" ').should == 'Text
|
24
|
+
ty('"текст"').should == '«текст»'
|
25
|
+
ty('Text "текст" text').should == 'Text «текст» text'
|
26
|
+
ty('Text "текст" text "Другой текст" ').should == 'Text «текст» text «Другой текст» '
|
27
27
|
end
|
28
28
|
|
29
29
|
it "should do the same with single quotes" do
|
30
|
-
ty('\'текст\'').should == '
|
31
|
-
ty('Text \'текст\' text').should == 'Text
|
32
|
-
ty('Text \'текст\' text \'Другой текст\' ').should == 'Text
|
30
|
+
ty('\'текст\'').should == '«текст»'
|
31
|
+
ty('Text \'текст\' text').should == 'Text «текст» text'
|
32
|
+
ty('Text \'текст\' text \'Другой текст\' ').should == 'Text «текст» text «Другой текст» '
|
33
33
|
end
|
34
34
|
|
35
35
|
|
36
36
|
it "should create second-level russian quotes" do
|
37
|
-
ty('Текст "в кавычках "второго уровня""').should == 'Текст
|
37
|
+
ty('Текст "в кавычках "второго уровня""').should == 'Текст «в кавычках „второго уровня“»'
|
38
38
|
end
|
39
39
|
|
40
40
|
|
@@ -57,7 +57,7 @@ describe TypographyHelper, 'with typography' do
|
|
57
57
|
|
58
58
|
it "should not replace quotes inside html tags" do
|
59
59
|
ty('<a href="ссылка">ссылка</a>').should == '<a href="ссылка">ссылка</a>'
|
60
|
-
ty('<a href=\'ссылка\'>"ссылка"</a>').should == '<a href=\'ссылка\'
|
60
|
+
ty('<a href=\'ссылка\'>"ссылка"</a>').should == '<a href=\'ссылка\'>«ссылка»</a>'
|
61
61
|
|
62
62
|
ty('<a href=\'link\'>link</a>').should == '<a href=\'link\'>link</a>'
|
63
63
|
ty('<a href="link">"link"</a>').should == '<a href="link">“link”</a>'
|
@@ -66,11 +66,11 @@ describe TypographyHelper, 'with typography' do
|
|
66
66
|
end
|
67
67
|
|
68
68
|
it "should make english and russian quotes in the same string" do
|
69
|
-
ty('"Кавычки" and "Quotes"').should == '
|
70
|
-
ty('"Quotes" и "Кавычки"').should == '“Quotes” и 
|
69
|
+
ty('"Кавычки" and "Quotes"').should == '«Кавычки» and “Quotes”'
|
70
|
+
ty('"Quotes" и "Кавычки"').should == '“Quotes” и «Кавычки»'
|
71
71
|
|
72
|
-
ty('"Кавычки "второго уровня"" and "Quotes "second level""').should == '
|
73
|
-
ty('"Quotes "second level"" и "Кавычки "второго уровня""').should == '“Quotes ‘second level’” и 
|
72
|
+
ty('"Кавычки "второго уровня"" and "Quotes "second level""').should == '«Кавычки „второго уровня“» and “Quotes ‘second level’”'
|
73
|
+
ty('"Quotes "second level"" и "Кавычки "второго уровня""').should == '“Quotes ‘second level’” и «Кавычки „второго уровня“»'
|
74
74
|
end
|
75
75
|
|
76
76
|
it "should make (“”) quotes in the same string" do
|
@@ -126,11 +126,11 @@ describe TypographyHelper, 'with typography' do
|
|
126
126
|
|
127
127
|
|
128
128
|
it "should typography real world examples" do
|
129
|
-
ty('"Читаешь -- "Прокопьев любил солянку" -- и долго не можешь понять, почему солянка написана с маленькой буквы, ведь "Солянка" -- известный московский клуб."').should == '
|
129
|
+
ty('"Читаешь -- "Прокопьев любил солянку" -- и долго не можешь понять, почему солянка написана с маленькой буквы, ведь "Солянка" -- известный московский клуб."').should == '«Читаешь — „Прокопьев любил солянку“ — и долго не можешь понять, почему солянка написана с маленькой буквы, ведь „Солянка“ — известный московский клуб.»'
|
130
130
|
end
|
131
131
|
|
132
132
|
it "should typography real world examples" do
|
133
|
-
ty('"Заебалоооооо" противостояние образует сет, в частности, "тюремные психозы", индуцируемые при различных психопатологических типологиях.', :escape_html => true).should == '
|
133
|
+
ty('"Заебалоооооо" противостояние образует сет, в частности, "тюремные психозы", индуцируемые при различных психопатологических типологиях.', :escape_html => true).should == '«Заебалоооооо» противостояние образует сет, в частности, «тюремные психозы», индуцируемые при различных психопатологических типологиях.'
|
134
134
|
end
|
135
135
|
|
136
136
|
it "should typography real world examples" do
|
@@ -150,7 +150,7 @@ describe TypographyHelper, 'with typography' do
|
|
150
150
|
end
|
151
151
|
|
152
152
|
it "should typography real world examples" do
|
153
|
-
ty('«Искусство после
|
153
|
+
ty('«Искусство после философии» – концептуальные стратегии Джозефа Кошута и Харальда Зеемана').should == '«Искусство после философии» — концептуальные стратегии Джозефа Кошута и Харальда Зеемана'
|
154
154
|
end
|
155
155
|
|
156
156
|
it "should typography real world examples" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: typography
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 0.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Dmitry Shaposhnik
|
@@ -109,7 +109,7 @@ rubyforge_project: ""
|
|
109
109
|
rubygems_version: 1.3.7
|
110
110
|
signing_key:
|
111
111
|
specification_version: 3
|
112
|
-
summary: typography-0.
|
112
|
+
summary: typography-0.3.0
|
113
113
|
test_files:
|
114
114
|
- spec/debug.log
|
115
115
|
- spec/spec_helper.rb
|