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.
@@ -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
@@ -1,4 +1,4 @@
1
1
  module TypographyHelper
2
2
  GEM_NAME = "typography"
3
- VERSION = "0.2.1"
3
+ VERSION = "0.3.0"
4
4
  end
@@ -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 == '&#171;текст&#187;'
25
- ty('Text "текст" text').should == 'Text &#171;текст&#187; text'
26
- ty('Text "текст" text "Другой текст" ').should == 'Text &#171;текст&#187; text &#171;Другой текст&#187; '
24
+ ty('"текст"').should == '&laquo;текст&raquo;'
25
+ ty('Text "текст" text').should == 'Text &laquo;текст&raquo; text'
26
+ ty('Text "текст" text "Другой текст" ').should == 'Text &laquo;текст&raquo; text &laquo;Другой текст&raquo; '
27
27
  end
28
28
 
29
29
  it "should do the same with single quotes" do
30
- ty('\'текст\'').should == '&#171;текст&#187;'
31
- ty('Text \'текст\' text').should == 'Text &#171;текст&#187; text'
32
- ty('Text \'текст\' text \'Другой текст\' ').should == 'Text &#171;текст&#187; text &#171;Другой текст&#187; '
30
+ ty('\'текст\'').should == '&laquo;текст&raquo;'
31
+ ty('Text \'текст\' text').should == 'Text &laquo;текст&raquo; text'
32
+ ty('Text \'текст\' text \'Другой текст\' ').should == 'Text &laquo;текст&raquo; text &laquo;Другой текст&raquo; '
33
33
  end
34
34
 
35
35
 
36
36
  it "should create second-level russian quotes" do
37
- ty('Текст "в кавычках "второго уровня""').should == 'Текст &#171;в&nbsp;кавычках &#132;второго уровня&#147;&#187;'
37
+ ty('Текст "в кавычках "второго уровня""').should == 'Текст &laquo;в&nbsp;кавычках &#132;второго уровня&#147;&raquo;'
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=\'ссылка\'>&#171;ссылка&#187;</a>'
60
+ ty('<a href=\'ссылка\'>"ссылка"</a>').should == '<a href=\'ссылка\'>&laquo;ссылка&raquo;</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">&#147;link&#148;</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 == '&#171;Кавычки&#187; and &#147;Quotes&#148;'
70
- ty('"Quotes" и "Кавычки"').should == '&#147;Quotes&#148; и&nbsp;&#171;Кавычки&#187;'
69
+ ty('"Кавычки" and "Quotes"').should == '&laquo;Кавычки&raquo; and &#147;Quotes&#148;'
70
+ ty('"Quotes" и "Кавычки"').should == '&#147;Quotes&#148; и&nbsp;&laquo;Кавычки&raquo;'
71
71
 
72
- ty('"Кавычки "второго уровня"" and "Quotes "second level""').should == '&#171;Кавычки &#132;второго уровня&#147;&#187; and &#147;Quotes &#145;second level&#146;&#148;'
73
- ty('"Quotes "second level"" и "Кавычки "второго уровня""').should == '&#147;Quotes &#145;second level&#146;&#148; и&nbsp;&#171;Кавычки &#132;второго уровня&#147;&#187;'
72
+ ty('"Кавычки "второго уровня"" and "Quotes "second level""').should == '&laquo;Кавычки &#132;второго уровня&#147;&raquo; and &#147;Quotes &#145;second level&#146;&#148;'
73
+ ty('"Quotes "second level"" и "Кавычки "второго уровня""').should == '&#147;Quotes &#145;second level&#146;&#148; и&nbsp;&laquo;Кавычки &#132;второго уровня&#147;&raquo;'
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 == '&#171;Читаешь&nbsp;&mdash; &#132;Прокопьев любил солянку&#147;&nbsp;&mdash; и&nbsp;долго не&nbsp;можешь понять, почему солянка написана с&nbsp;маленькой буквы, ведь &#132;Солянка&#147;&nbsp;&mdash; известный московский клуб.&#187;'
129
+ ty('"Читаешь -- "Прокопьев любил солянку" -- и долго не можешь понять, почему солянка написана с маленькой буквы, ведь "Солянка" -- известный московский клуб."').should == '&laquo;Читаешь&nbsp;&mdash; &#132;Прокопьев любил солянку&#147;&nbsp;&mdash; и&nbsp;долго не&nbsp;можешь понять, почему солянка написана с&nbsp;маленькой буквы, ведь &#132;Солянка&#147;&nbsp;&mdash; известный московский клуб.&raquo;'
130
130
  end
131
131
 
132
132
  it "should typography real world examples" do
133
- ty('"Заебалоооооо" противостояние образует сет, в частности, "тюремные психозы", индуцируемые при различных психопатологических типологиях.', :escape_html => true).should == '&#171;Заебалоооооо&#187; противостояние образует сет, в&nbsp;частности, &#171;тюремные психозы&#187;, индуцируемые при различных психопатологических типологиях.'
133
+ ty('"Заебалоооооо" противостояние образует сет, в частности, "тюремные психозы", индуцируемые при различных психопатологических типологиях.', :escape_html => true).should == '&laquo;Заебалоооооо&raquo; противостояние образует сет, в&nbsp;частности, &laquo;тюремные психозы&raquo;, индуцируемые при различных психопатологических типологиях.'
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('«Искусство после философии&#187; – концептуальные стратегии Джозефа Кошута и Харальда Зеемана').should == '«Искусство после философии&#187;&nbsp;&mdash; концептуальные стратегии Джозефа Кошута и&nbsp;Харальда Зеемана'
153
+ ty('«Искусство после философии&raquo; – концептуальные стратегии Джозефа Кошута и Харальда Зеемана').should == '«Искусство после философии&raquo;&nbsp;&mdash; концептуальные стратегии Джозефа Кошута и&nbsp;Харальда Зеемана'
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: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 2
9
- - 1
10
- version: 0.2.1
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.2.1
112
+ summary: typography-0.3.0
113
113
  test_files:
114
114
  - spec/debug.log
115
115
  - spec/spec_helper.rb