typogruby 1.0.8 → 1.0.9

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 CHANGED
@@ -1,12 +1,10 @@
1
1
  source :rubyforge
2
2
  gem 'rubypants'
3
3
 
4
- group :development do
4
+ group :development, :test do
5
5
  gem 'yard'
6
6
  gem 'jeweler'
7
- end
8
-
9
- group :test do
7
+ gem 'rake'
10
8
  gem 'aruba'
11
9
  gem 'cucumber'
12
10
  end
@@ -24,6 +24,7 @@ GEM
24
24
  rubyforge (>= 2.0.0)
25
25
  json (1.4.6)
26
26
  json_pure (1.4.6)
27
+ rake (0.8.7)
27
28
  rubyforge (2.0.4)
28
29
  json_pure (>= 1.1.7)
29
30
  rubypants (0.2.0)
@@ -37,5 +38,6 @@ DEPENDENCIES
37
38
  aruba
38
39
  cucumber
39
40
  jeweler
41
+ rake
40
42
  rubypants
41
43
  yard
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'rubygems'
2
2
  require 'rake'
3
- require 'bundler'
3
+ require 'bundler/setup'
4
4
 
5
5
  begin
6
6
  require 'jeweler'
@@ -38,8 +38,6 @@ rescue LoadError
38
38
  end
39
39
  end
40
40
 
41
- task :test => :check_dependencies
42
-
43
41
  task :default => :test
44
42
 
45
43
  begin
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.8
1
+ 1.0.9
@@ -137,6 +137,10 @@ module Typogruby
137
137
  # caps("A message from 2KU2 with digits")
138
138
  # # => 'A message from <span class="caps">2KU2</span> with digits'
139
139
  #
140
+ # @example Ignores HTML attributes
141
+ # caps('Download <a href="file.doc" title="PDF document">this file</a>')
142
+ # # => 'Download <a href="file.doc" title="PDF document">this file</a>'
143
+ #
140
144
  # @example All caps with with apostrophes in them shouldn't break. Only handles dump apostrophes though.
141
145
  # caps("JIMMY'S")
142
146
  # # => '<span class="caps">JIMMY\\'S</span>'
@@ -147,10 +151,19 @@ module Typogruby
147
151
  # @return [String] input text with caps wrapped
148
152
  def caps(text)
149
153
  ignore_scripts(text) do |t|
150
- # $1 is an excluded HTML tag, $2 is the part before the caps and $3 is the caps match
151
- t.gsub(/(?i:<(:code|pre).+?<\/\1>)|(\s|&nbsp;|^|'|"|>)([A-Z\d][A-Z\d\.']{1,})(?!\w)/) do |str|
152
- excluded, before, caps = $1, $2, $3
153
- if excluded
154
+ # $1 and $2 are excluded HTML tags, $3 is the part before the caps and $4 is the caps match
155
+ t.gsub(%r{
156
+ (?i:<(code|pre).+?</\1>)| # Ignore the contents of code and pre elements
157
+ (<[^/][^>]+?>)| # Ignore any opening tag, so we don't mess up attribute values
158
+ (\s|&nbsp;|^|'|"|>) # Make sure our capture is preceded by whitespace or quotes
159
+ ([A-Z\d][A-Z\d\.']{1,}) # Capture captial words, with optional dots or numbers in between
160
+ (?!\w) # ...which must not be followed by a word character.
161
+ }x) do |str|
162
+ excluded, tag, before, caps = $1, $2, $3, $4
163
+
164
+ # Do nothing with the contents if ignored tags, the inside of an opening HTML element
165
+ # so we don't mess up attribute values, or if our capture is only digits.
166
+ if excluded || tag || caps =~ /^\d+\.?$/
154
167
  str
155
168
  elsif $3 =~ /^[\d\.]+$/
156
169
  before + caps
@@ -35,7 +35,7 @@ class TestTypogruby < Test::Unit::TestCase
35
35
  assert_equal '<Pre>CAPS</PRE> with odd tag names <span class="caps">CAPS</span>', caps("<Pre>CAPS</PRE> with odd tag names CAPS")
36
36
  assert_equal 'A message from <span class="caps">2KU2</span> with digits', caps("A message from 2KU2 with digits")
37
37
  assert_equal 'Dotted caps followed by spaces should never include them in the wrap <span class="caps">D.O.T.</span> like so.', caps("Dotted caps followed by spaces should never include them in the wrap D.O.T. like so.")
38
- assert_equal %Q{<script>\nvar x = "FOO BAR and BAZ";\n</script>"}, initial_quotes(%Q{<script>\nvar x = "FOO BAR and BAZ";\n</script>"})
38
+ assert_equal 'Caps in attributes (<span title="Example CAPS">example</span>) should be ignored', caps('Caps in attributes (<span title="Example CAPS">example</span>) should be ignored')
39
39
  end
40
40
 
41
41
  def test_should_not_break_caps_with_apostrophes
@@ -49,6 +49,7 @@ class TestTypogruby < Test::Unit::TestCase
49
49
  assert_equal '<a href="#"><span class="dquo">"</span>With primes and a link"</a>', initial_quotes('<a href="#">"With primes and a link"</a>')
50
50
  assert_equal '<span class="dquo">&#8220;</span>With smartypanted quotes&#8221;', initial_quotes('&#8220;With smartypanted quotes&#8221;')
51
51
  assert_equal '<span class="quo">&lsquo;</span>With manual quotes&rsquo;', initial_quotes('&lsquo;With manual quotes&rsquo;')
52
+ assert_equal %Q{<script>\nvar x = "FOO BAR and BAZ";\n</script>"}, initial_quotes(%Q{<script>\nvar x = "FOO BAR and BAZ";\n</script>"})
52
53
  end
53
54
 
54
55
  def test_should_not_replace_quotes_in_scripts
@@ -0,0 +1,79 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{typogruby}
8
+ s.version = "1.0.9"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Arjan van der Gaag"]
12
+ s.date = %q{2011-02-14}
13
+ s.default_executable = %q{typogruby}
14
+ s.description = %q{Improve web typography using various text filters. This gem prevents widows and applies markup to ampersans, consecutive capitals and initial quotes.}
15
+ s.email = %q{arjan@arjanvandergaag.nl}
16
+ s.executables = ["typogruby"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE",
19
+ "README.md"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ ".gitignore",
24
+ "Gemfile",
25
+ "Gemfile.lock",
26
+ "HISTORY.md",
27
+ "LICENSE",
28
+ "README.md",
29
+ "Rakefile",
30
+ "VERSION",
31
+ "bin/typogruby",
32
+ "features/ignoring.feature",
33
+ "features/inputs.feature",
34
+ "features/selective_filtering.feature",
35
+ "features/simple.feature",
36
+ "features/support/env.rb",
37
+ "lib/characters.txt",
38
+ "lib/typogruby.rb",
39
+ "test/test_typogruby.rb",
40
+ "typogrify.gemspec",
41
+ "typogruby.gemspec"
42
+ ]
43
+ s.homepage = %q{http://avdgaag.github.com/typogruby}
44
+ s.rdoc_options = ["--charset=UTF-8"]
45
+ s.require_paths = ["lib"]
46
+ s.rubygems_version = %q{1.5.0}
47
+ s.summary = %q{Improves web typography like Django's Typogrify}
48
+ s.test_files = [
49
+ "test/test_typogruby.rb"
50
+ ]
51
+
52
+ if s.respond_to? :specification_version then
53
+ s.specification_version = 3
54
+
55
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
56
+ s.add_runtime_dependency(%q<rubypants>, [">= 0"])
57
+ s.add_development_dependency(%q<yard>, [">= 0"])
58
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
59
+ s.add_development_dependency(%q<rake>, [">= 0"])
60
+ s.add_development_dependency(%q<aruba>, [">= 0"])
61
+ s.add_development_dependency(%q<cucumber>, [">= 0"])
62
+ else
63
+ s.add_dependency(%q<rubypants>, [">= 0"])
64
+ s.add_dependency(%q<yard>, [">= 0"])
65
+ s.add_dependency(%q<jeweler>, [">= 0"])
66
+ s.add_dependency(%q<rake>, [">= 0"])
67
+ s.add_dependency(%q<aruba>, [">= 0"])
68
+ s.add_dependency(%q<cucumber>, [">= 0"])
69
+ end
70
+ else
71
+ s.add_dependency(%q<rubypants>, [">= 0"])
72
+ s.add_dependency(%q<yard>, [">= 0"])
73
+ s.add_dependency(%q<jeweler>, [">= 0"])
74
+ s.add_dependency(%q<rake>, [">= 0"])
75
+ s.add_dependency(%q<aruba>, [">= 0"])
76
+ s.add_dependency(%q<cucumber>, [">= 0"])
77
+ end
78
+ end
79
+
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: 7
5
- prerelease: false
4
+ hash: 5
5
+ prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 8
10
- version: 1.0.8
9
+ - 9
10
+ version: 1.0.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - Arjan van der Gaag
@@ -15,14 +15,26 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-06 00:00:00 +01:00
18
+ date: 2011-02-14 00:00:00 +01:00
19
19
  default_executable: typogruby
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  type: :runtime
23
- prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
24
32
  name: rubypants
25
- version_requirements: &id001 !ruby/object:Gem::Requirement
33
+ version_requirements: *id001
34
+ prerelease: false
35
+ - !ruby/object:Gem::Dependency
36
+ type: :development
37
+ requirement: &id002 !ruby/object:Gem::Requirement
26
38
  none: false
27
39
  requirements:
28
40
  - - ">="
@@ -31,12 +43,26 @@ dependencies:
31
43
  segments:
32
44
  - 0
33
45
  version: "0"
34
- requirement: *id001
46
+ name: yard
47
+ version_requirements: *id002
48
+ prerelease: false
35
49
  - !ruby/object:Gem::Dependency
36
50
  type: :development
51
+ requirement: &id003 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ hash: 3
57
+ segments:
58
+ - 0
59
+ version: "0"
60
+ name: jeweler
61
+ version_requirements: *id003
37
62
  prerelease: false
38
- name: yard
39
- version_requirements: &id002 !ruby/object:Gem::Requirement
63
+ - !ruby/object:Gem::Dependency
64
+ type: :development
65
+ requirement: &id004 !ruby/object:Gem::Requirement
40
66
  none: false
41
67
  requirements:
42
68
  - - ">="
@@ -45,12 +71,26 @@ dependencies:
45
71
  segments:
46
72
  - 0
47
73
  version: "0"
48
- requirement: *id002
74
+ name: rake
75
+ version_requirements: *id004
76
+ prerelease: false
49
77
  - !ruby/object:Gem::Dependency
50
78
  type: :development
79
+ requirement: &id005 !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ hash: 3
85
+ segments:
86
+ - 0
87
+ version: "0"
88
+ name: aruba
89
+ version_requirements: *id005
51
90
  prerelease: false
52
- name: jeweler
53
- version_requirements: &id003 !ruby/object:Gem::Requirement
91
+ - !ruby/object:Gem::Dependency
92
+ type: :development
93
+ requirement: &id006 !ruby/object:Gem::Requirement
54
94
  none: false
55
95
  requirements:
56
96
  - - ">="
@@ -59,7 +99,9 @@ dependencies:
59
99
  segments:
60
100
  - 0
61
101
  version: "0"
62
- requirement: *id003
102
+ name: cucumber
103
+ version_requirements: *id006
104
+ prerelease: false
63
105
  description: Improve web typography using various text filters. This gem prevents widows and applies markup to ampersans, consecutive capitals and initial quotes.
64
106
  email: arjan@arjanvandergaag.nl
65
107
  executables:
@@ -89,6 +131,7 @@ files:
89
131
  - lib/typogruby.rb
90
132
  - test/test_typogruby.rb
91
133
  - typogrify.gemspec
134
+ - typogruby.gemspec
92
135
  has_rdoc: true
93
136
  homepage: http://avdgaag.github.com/typogruby
94
137
  licenses: []
@@ -119,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
162
  requirements: []
120
163
 
121
164
  rubyforge_project:
122
- rubygems_version: 1.3.7
165
+ rubygems_version: 1.5.0
123
166
  signing_key:
124
167
  specification_version: 3
125
168
  summary: Improves web typography like Django's Typogrify