typogruby 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY.md +35 -0
- data/README.md +10 -54
- data/Rakefile +7 -1
- data/VERSION +1 -1
- data/lib/typogruby.rb +13 -6
- data/test/test_typogruby.rb +7 -1
- metadata +5 -6
- data/test/helper.rb +0 -13
data/HISTORY.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## 1.0.7
|
4
|
+
|
5
|
+
* Improved Ruby 1.9 compatibility
|
6
|
+
* Improved documentation
|
7
|
+
* Merged test helper and test case
|
8
|
+
|
9
|
+
## 1.0.6
|
10
|
+
|
11
|
+
* Bugfix: ignore inline javascript
|
12
|
+
|
13
|
+
## 1.0.5
|
14
|
+
|
15
|
+
* Manage gem dependencies using Bundler
|
16
|
+
|
17
|
+
## 1.0.4
|
18
|
+
|
19
|
+
* Bugfix: no longer regard combination of digits and periods as caps.
|
20
|
+
* Bugfix: do not add consecutive non-breaking spaces to prevent widows
|
21
|
+
|
22
|
+
## 1.0.3
|
23
|
+
|
24
|
+
* Bugfix: caps also ignores unequal but same excepted tags
|
25
|
+
* Feature: added command-line program
|
26
|
+
* Improved documentation
|
27
|
+
|
28
|
+
## 1.0.2
|
29
|
+
|
30
|
+
* Bugfix: initial_quotes also wraps named HTML entities
|
31
|
+
* Bugfix: caps no longer wraps consecutive numbers
|
32
|
+
|
33
|
+
## 1.0
|
34
|
+
|
35
|
+
* First release
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# Typogruby
|
2
2
|
|
3
3
|
Helps you improve your web typograpbhy with some standard text filters.
|
4
4
|
|
@@ -39,41 +39,9 @@ This will output the contents of your file with all filters applied. Use `typogr
|
|
39
39
|
* ...and on [Typogrify][3]
|
40
40
|
* [Description of typogrify][1]
|
41
41
|
|
42
|
-
[1]: http://jeffcroft.com/blog/2007/may/29/typogrify-easily-produce-web-typography-doesnt-suc/
|
43
|
-
[2]: http://github.com/hunter/typography-helper
|
44
|
-
[3]: http://code.google.com/p/typogrify
|
45
|
-
[4]: http://avdgaag.github.com/typogruby
|
46
|
-
[5]: http://github.com/avdgaag/Typography-tmbundle
|
47
|
-
|
48
42
|
## Changelog
|
49
43
|
|
50
|
-
|
51
|
-
|
52
|
-
* Bugfix: ignore inline javascript
|
53
|
-
|
54
|
-
### 1.0.5
|
55
|
-
|
56
|
-
* Manage gem dependencies using Bundler
|
57
|
-
|
58
|
-
### 1.0.4
|
59
|
-
|
60
|
-
* Bugfix: no longer regard combination of digits and periods as caps.
|
61
|
-
* Bugfix: do not add consecutive non-breaking spaces to prevent widows
|
62
|
-
|
63
|
-
### 1.0.3
|
64
|
-
|
65
|
-
* Bugfix: caps also ignores unequal but same excepted tags
|
66
|
-
* Feature: added command-line program
|
67
|
-
* Improved documentation
|
68
|
-
|
69
|
-
### 1.0.2
|
70
|
-
|
71
|
-
* Bugfix: initial_quotes also wraps named HTML entities
|
72
|
-
* Bugfix: caps no longer wraps consecutive numbers
|
73
|
-
|
74
|
-
### 1.0
|
75
|
-
|
76
|
-
* First release
|
44
|
+
See HISTORY.md for the complete changelog.
|
77
45
|
|
78
46
|
## Note on Patches/Pull Requests
|
79
47
|
|
@@ -85,25 +53,13 @@ This will output the contents of your file with all filters applied. Use `typogr
|
|
85
53
|
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
86
54
|
* Send me a pull request. Bonus points for topic branches.
|
87
55
|
|
88
|
-
##
|
89
|
-
|
90
|
-
Copyright (c) 2010 Arjan van der Gaag
|
56
|
+
## Credits
|
91
57
|
|
92
|
-
|
93
|
-
a copy of this software and associated documentation files (the
|
94
|
-
"Software"), to deal in the Software without restriction, including
|
95
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
96
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
97
|
-
permit persons to whom the Software is furnished to do so, subject to
|
98
|
-
the following conditions:
|
58
|
+
By Arjan van der Gaag ([avdgaag @ github][6]) based on the hard work of lots of others. See LICENSE for license details (same as Ruby).
|
99
59
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
107
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
108
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
109
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
60
|
+
[1]: http://jeffcroft.com/blog/2007/may/29/typogrify-easily-produce-web-typography-doesnt-suc/
|
61
|
+
[2]: http://github.com/hunter/typography-helper
|
62
|
+
[3]: http://code.google.com/p/typogrify
|
63
|
+
[4]: http://avdgaag.github.com/typogruby
|
64
|
+
[5]: http://github.com/avdgaag/Typography-tmbundle
|
65
|
+
[6]: http://github.com/avdgaag
|
data/Rakefile
CHANGED
@@ -44,7 +44,13 @@ task :default => :test
|
|
44
44
|
|
45
45
|
begin
|
46
46
|
require 'yard'
|
47
|
-
YARD::Rake::YardocTask.new
|
47
|
+
YARD::Rake::YardocTask.new do |t|
|
48
|
+
t.options = [
|
49
|
+
'--files', 'LICENSE',
|
50
|
+
'--files', 'HISTORY.md',
|
51
|
+
'--title', 'Typogruby API documentation'
|
52
|
+
]
|
53
|
+
end
|
48
54
|
rescue LoadError
|
49
55
|
task :yardoc do
|
50
56
|
abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.7
|
data/lib/typogruby.rb
CHANGED
@@ -4,6 +4,13 @@ require 'digest/md5'
|
|
4
4
|
# A collection of simple helpers for improving web
|
5
5
|
# typograhy. Based on TypographyHelper by Luke Hartman and Typogrify.
|
6
6
|
#
|
7
|
+
# @example Using all filters
|
8
|
+
# require 'typogruby'
|
9
|
+
# Typogruby.improve('my text')
|
10
|
+
#
|
11
|
+
# @example Using a single filter
|
12
|
+
# Typogruby.initial_quotes('my text')
|
13
|
+
#
|
7
14
|
# @see http://github.com/hunter/typography-helper
|
8
15
|
# @see http://code.google.com/p/typogrify
|
9
16
|
# @author Arjan van der Gaag <arjan.vandergaag@gmail.com>
|
@@ -28,7 +35,7 @@ module Typogruby
|
|
28
35
|
end
|
29
36
|
|
30
37
|
# converts a & surrounded by optional whitespace or a non-breaking space
|
31
|
-
# to the HTML entity and surrounds it in a span with a styled class
|
38
|
+
# to the HTML entity and surrounds it in a span with a styled class.
|
32
39
|
#
|
33
40
|
# @example
|
34
41
|
# amp('One & two')
|
@@ -65,7 +72,7 @@ module Typogruby
|
|
65
72
|
# replaces space(s) before the last word (or tag before the last word)
|
66
73
|
# before an optional closing element (<tt>a</tt>, <tt>em</tt>,
|
67
74
|
# <tt>span</tt>, strong) before a closing tag (<tt>p</tt>, <tt>h[1-6]</tt>,
|
68
|
-
# <tt>li</tt>, <tt>dt</tt>, <tt>dd</tt>) or the end of the string
|
75
|
+
# <tt>li</tt>, <tt>dt</tt>, <tt>dd</tt>) or the end of the string.
|
69
76
|
#
|
70
77
|
# @example
|
71
78
|
# > widont('A very simple test')
|
@@ -119,7 +126,7 @@ module Typogruby
|
|
119
126
|
end
|
120
127
|
|
121
128
|
# surrounds two or more consecutive captial letters, perhaps with interspersed digits and periods
|
122
|
-
# in a span with a styled class
|
129
|
+
# in a span with a styled class.
|
123
130
|
#
|
124
131
|
# @example
|
125
132
|
# caps("A message from KU")
|
@@ -140,7 +147,7 @@ module Typogruby
|
|
140
147
|
def caps(text)
|
141
148
|
ignore_scripts(text) do |t|
|
142
149
|
# $1 is an excluded HTML tag, $2 is the part before the caps and $3 is the caps match
|
143
|
-
t.gsub(
|
150
|
+
t.gsub(/(?i:<(:code|pre).+?<\/\1>)|(\s| |^|'|"|>)([A-Z\d][A-Z\d\.']{1,})(?!\w)/) do |str|
|
144
151
|
excluded, before, caps = $1, $2, $3
|
145
152
|
if excluded
|
146
153
|
str
|
@@ -155,7 +162,7 @@ module Typogruby
|
|
155
162
|
|
156
163
|
# encloses initial single or double quote, or their entities
|
157
164
|
# (optionally preceeded by a block element and perhaps an inline element)
|
158
|
-
# with a span that can be styled
|
165
|
+
# with a span that can be styled.
|
159
166
|
#
|
160
167
|
# @example
|
161
168
|
# initial_quotes('"With primes"')
|
@@ -180,7 +187,7 @@ module Typogruby
|
|
180
187
|
end
|
181
188
|
end
|
182
189
|
|
183
|
-
# main function to do all the functions from the method
|
190
|
+
# main function to do all the functions from the method.
|
184
191
|
# @param [String] text input text
|
185
192
|
# @return [String] input text with all filters applied
|
186
193
|
def improve(text)
|
data/test/test_typogruby.rb
CHANGED
@@ -1,6 +1,12 @@
|
|
1
|
-
require '
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
require 'test/unit'
|
4
|
+
require 'typogruby'
|
5
|
+
Bundler.setup
|
6
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
7
|
|
3
8
|
class TestTypogruby < Test::Unit::TestCase
|
9
|
+
include Typogruby
|
4
10
|
|
5
11
|
def test_should_replace_amps
|
6
12
|
assert_equal 'One <span class="amp">&</span> two', amp('One & two')
|
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:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 7
|
10
|
+
version: 1.0.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Arjan van der Gaag
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-08-
|
18
|
+
date: 2010-08-23 00:00:00 +02:00
|
19
19
|
default_executable: typogruby
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -73,13 +73,13 @@ files:
|
|
73
73
|
- .document
|
74
74
|
- .gitignore
|
75
75
|
- Gemfile
|
76
|
+
- HISTORY.md
|
76
77
|
- LICENSE
|
77
78
|
- README.md
|
78
79
|
- Rakefile
|
79
80
|
- VERSION
|
80
81
|
- bin/typogruby
|
81
82
|
- lib/typogruby.rb
|
82
|
-
- test/helper.rb
|
83
83
|
- test/test_typogruby.rb
|
84
84
|
- typogrify.gemspec
|
85
85
|
has_rdoc: true
|
@@ -117,5 +117,4 @@ signing_key:
|
|
117
117
|
specification_version: 3
|
118
118
|
summary: Improves web typography like Django's Typogrify
|
119
119
|
test_files:
|
120
|
-
- test/helper.rb
|
121
120
|
- test/test_typogruby.rb
|
data/test/helper.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'bundler'
|
3
|
-
require 'test/unit'
|
4
|
-
|
5
|
-
Bundler.setup
|
6
|
-
|
7
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
8
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
9
|
-
require 'typogruby'
|
10
|
-
|
11
|
-
class Test::Unit::TestCase
|
12
|
-
include Typogruby
|
13
|
-
end
|