typogruby 1.0.13 → 1.0.14

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/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- typogruby (1.0.13)
4
+ typogruby (1.0.14)
5
5
  rubypants
6
6
 
7
7
  GEM
data/HISTORY.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.14
4
+
5
+ * Bugfix: ignore multi-line HTML attributes in widont filter
6
+
3
7
  ## 1.0.13
4
8
 
5
9
  * Be smart about periods in abbreviations. Capitalise LA, L.A. and L.A, but not L. or L. A. (by Brad Weslake)
data/README.md CHANGED
@@ -14,14 +14,18 @@ First, install the Ruby gem:
14
14
 
15
15
  Then require the library to get started:
16
16
 
17
- require 'typogruby'
18
- Typogruby.improve('Hello, world!')
17
+ ```ruby
18
+ require 'typogruby'
19
+ Typogruby.improve('Hello, world!')
20
+ ```
19
21
 
20
22
  Or, you can include the library in a helper or something:
21
23
 
22
- require 'typogruby'
23
- include Typogruby
24
- improve('Hello, world!')
24
+ ```ruby
25
+ require 'typogruby'
26
+ include Typogruby
27
+ improve('Hello, world!')
28
+ ```
25
29
 
26
30
  See the [full API documentation][4] for more information. You could also use [this Textmate Bundle][5].
27
31
 
data/lib/typogruby.rb CHANGED
@@ -112,13 +112,14 @@ module Typogruby
112
112
  def widont(text)
113
113
  exclude_sensitive_tags(text) do |t|
114
114
  t.gsub(%r{
115
+ (<[^/][^>]*?>)| # Ignore any opening tag, so we don't mess up attribute values
115
116
  ((?:</?(?:a|em|span|strong|i|b)[^>]*>)|[^<>\s]) # must be proceeded by an approved inline opening or closing tag or a nontag/nonspace
116
117
  \s+ # the space to replace
117
118
  (([^<>\s]+) # must be flollowed by non-tag non-space characters
118
119
  \s* # optional white space!
119
120
  (</(a|em|span|strong|i|b)>\s*)* # optional closing inline tags with optional white space after each
120
121
  ((</(p|h[1-6]|li|dt|dd)>)|$)) # end with a closing p, h1-6, li or the end of the string
121
- }x) { |match| $1 + (match.include?('&nbsp;') ? ' ' : '&nbsp;') + $2 } # Make sure to not add another nbsp before one already there
122
+ }xm) { |match| $1 ? match : $2 + (match.include?('&nbsp;') ? ' ' : '&nbsp;') + $3 } # Make sure to not add another nbsp before one already there
122
123
  end
123
124
  end
124
125
 
@@ -155,10 +156,10 @@ module Typogruby
155
156
  exclude_sensitive_tags(text) do |t|
156
157
  # $1 and $2 are excluded HTML tags, $3 is the part before the caps and $4 is the caps match
157
158
  t.gsub(%r{
158
- (<[^/][^>]+?>)| # Ignore any opening tag, so we don't mess up attribute values
159
- (\s|&nbsp;|^|'|"|>) # Make sure our capture is preceded by whitespace or quotes
160
- ([A-Z\d]([\.']?[A-Z\d][\.']?){1,}) # Capture capital words, with optional dots or numbers in between
161
- (?!\w) # ...which must not be followed by a word character.
159
+ (<[^/][^>]*?>)| # Ignore any opening tag, so we don't mess up attribute values
160
+ (\s|&nbsp;|^|'|"|>|) # Make sure our capture is preceded by whitespace or quotes
161
+ ([A-Z\d](?:[\.']?[A-Z\d][\.']?){1,}) # Capture capital words, with optional dots or numbers in between
162
+ (?!\w) # ...which must not be followed by a word character.
162
163
  }x) do |str|
163
164
  tag, before, caps = $1, $2, $3
164
165
 
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Typogruby
2
- VERSION = '1.0.13'
2
+ VERSION = '1.0.14'
3
3
  end
@@ -1,9 +1,6 @@
1
- require 'rubygems'
2
- require 'bundler'
1
+ # -*- encoding: utf-8 -*-
3
2
  require 'test/unit'
4
3
  require 'typogruby'
5
- Bundler.setup
6
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
7
4
 
8
5
  class TestTypogruby < Test::Unit::TestCase
9
6
  include Typogruby
@@ -27,6 +24,8 @@ class TestTypogruby < Test::Unit::TestCase
27
24
 
28
25
  def test_should_replace_caps
29
26
  assert_equal 'A message from <span class="caps">KU</span>', caps("A message from KU")
27
+ assert_equal 'Replace text <a href="."><span class="caps">IN</span></a> tags', caps('Replace text <a href=".">IN</a> tags')
28
+ assert_equal 'Replace text <i><span class="caps">IN</span></i> tags', caps('Replace text <i>IN</i> tags')
30
29
  end
31
30
 
32
31
  def test_should_ignore_special_case_caps
@@ -93,6 +92,11 @@ class TestTypogruby < Test::Unit::TestCase
93
92
  assert_equal '<div><p>But divs with paragraphs&nbsp;do!</p></div>', widont('<div><p>But divs with paragraphs do!</p></div>')
94
93
  end
95
94
 
95
+ def test_should_ignore_attributes_across_mutliple_lines_when_preventing_widows
96
+ assert_equal %Q{<div id="aniver" style="\nbackground-image:url('/static/colorfulbackground.png');\nbackground-repeat:no-repeat;\ntext-align:center;\nmargin:0;\npadding:0;\nbackground-size: 100% 100%;">},
97
+ widont(%Q{<div id="aniver" style="\nbackground-image:url('/static/colorfulbackground.png');\nbackground-repeat:no-repeat;\ntext-align:center;\nmargin:0;\npadding:0;\nbackground-size: 100% 100%;">})
98
+ end
99
+
96
100
  def test_should_convert_entities
97
101
  assert_equal "Vari&euml;ren&hellip;", entities('Variëren…')
98
102
  assert_equal "<p>Ol&eacute;</p>", entities('<p>Olé</p>')
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typogruby
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 13
10
- version: 1.0.13
9
+ - 14
10
+ version: 1.0.14
11
11
  platform: ruby
12
12
  authors:
13
13
  - Arjan van der Gaag
@@ -15,10 +15,10 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-23 00:00:00 Z
18
+ date: 2012-01-26 00:00:00 +01:00
19
+ default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
- type: :runtime
22
22
  prerelease: false
23
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
24
  none: false
@@ -29,10 +29,10 @@ dependencies:
29
29
  segments:
30
30
  - 0
31
31
  version: "0"
32
- version_requirements: *id001
32
+ type: :runtime
33
33
  name: rubypants
34
+ version_requirements: *id001
34
35
  - !ruby/object:Gem::Dependency
35
- type: :development
36
36
  prerelease: false
37
37
  requirement: &id002 !ruby/object:Gem::Requirement
38
38
  none: false
@@ -43,10 +43,10 @@ dependencies:
43
43
  segments:
44
44
  - 0
45
45
  version: "0"
46
- version_requirements: *id002
46
+ type: :development
47
47
  name: yard
48
+ version_requirements: *id002
48
49
  - !ruby/object:Gem::Dependency
49
- type: :development
50
50
  prerelease: false
51
51
  requirement: &id003 !ruby/object:Gem::Requirement
52
52
  none: false
@@ -57,10 +57,10 @@ dependencies:
57
57
  segments:
58
58
  - 0
59
59
  version: "0"
60
- version_requirements: *id003
60
+ type: :development
61
61
  name: rake
62
+ version_requirements: *id003
62
63
  - !ruby/object:Gem::Dependency
63
- type: :development
64
64
  prerelease: false
65
65
  requirement: &id004 !ruby/object:Gem::Requirement
66
66
  none: false
@@ -71,10 +71,10 @@ dependencies:
71
71
  segments:
72
72
  - 0
73
73
  version: "0"
74
- version_requirements: *id004
74
+ type: :development
75
75
  name: aruba
76
+ version_requirements: *id004
76
77
  - !ruby/object:Gem::Dependency
77
- type: :development
78
78
  prerelease: false
79
79
  requirement: &id005 !ruby/object:Gem::Requirement
80
80
  none: false
@@ -85,10 +85,10 @@ dependencies:
85
85
  segments:
86
86
  - 0
87
87
  version: "0"
88
- version_requirements: *id005
88
+ type: :development
89
89
  name: cucumber
90
+ version_requirements: *id005
90
91
  - !ruby/object:Gem::Dependency
91
- type: :development
92
92
  prerelease: false
93
93
  requirement: &id006 !ruby/object:Gem::Requirement
94
94
  none: false
@@ -99,10 +99,10 @@ dependencies:
99
99
  segments:
100
100
  - 0
101
101
  version: "0"
102
- version_requirements: *id006
102
+ type: :development
103
103
  name: rcov
104
+ version_requirements: *id006
104
105
  - !ruby/object:Gem::Dependency
105
- type: :development
106
106
  prerelease: false
107
107
  requirement: &id007 !ruby/object:Gem::Requirement
108
108
  none: false
@@ -113,10 +113,10 @@ dependencies:
113
113
  segments:
114
114
  - 0
115
115
  version: "0"
116
- version_requirements: *id007
116
+ type: :development
117
117
  name: rspec
118
+ version_requirements: *id007
118
119
  - !ruby/object:Gem::Dependency
119
- type: :development
120
120
  prerelease: false
121
121
  requirement: &id008 !ruby/object:Gem::Requirement
122
122
  none: false
@@ -127,8 +127,9 @@ dependencies:
127
127
  segments:
128
128
  - 0
129
129
  version: "0"
130
- version_requirements: *id008
130
+ type: :development
131
131
  name: bluecloth
132
+ version_requirements: *id008
132
133
  description: Improve web typography using various text filters. This gem prevents widows and applies markup to ampersans, consecutive capitals and initial quotes.
133
134
  email: arjan@arjanvandergaag.nl
134
135
  executables:
@@ -160,6 +161,7 @@ files:
160
161
  - lib/version.rb
161
162
  - test/test_typogruby.rb
162
163
  - typogruby.gemspec
164
+ has_rdoc: true
163
165
  homepage: http://avdgaag.github.com/typogruby
164
166
  licenses: []
165
167
 
@@ -189,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
191
  requirements: []
190
192
 
191
193
  rubyforge_project:
192
- rubygems_version: 1.8.10
194
+ rubygems_version: 1.6.2
193
195
  signing_key:
194
196
  specification_version: 3
195
197
  summary: Improves web typography like Django's Typogrify