typogruby 1.0.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/.document +5 -0
- data/.gitignore +23 -0
- data/LICENSE +20 -0
- data/README.md +67 -0
- data/Rakefile +53 -0
- data/VERSION +1 -0
- data/lib/typogruby.rb +173 -0
- data/test/helper.rb +10 -0
- data/test/test_typogruby.rb +74 -0
- data/typogrify.gemspec +56 -0
- metadata +105 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Arjan van der Gaag
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# typogruby
|
2
|
+
|
3
|
+
Helps you improve your web typograpbhy with some standard text filters.
|
4
|
+
|
5
|
+
This project is based on Django's Typogrify, so the best introduction to read would be [Jeff Croft's][1].
|
6
|
+
|
7
|
+
I created this gem to easily share these text filters in some tiny Ruby projects, including a TextMate bundle. For production code I recommend checking out the originals first.
|
8
|
+
|
9
|
+
## General Usage
|
10
|
+
|
11
|
+
First, install the Ruby gem:
|
12
|
+
|
13
|
+
$ gem install typogruby
|
14
|
+
|
15
|
+
Then require the library to get started:
|
16
|
+
|
17
|
+
require 'typogruby'
|
18
|
+
Typogruby.improve('Hello, world!')
|
19
|
+
|
20
|
+
Or, you can include the library in a helper or something:
|
21
|
+
|
22
|
+
require 'typogruby'
|
23
|
+
include Typogruby
|
24
|
+
improve('Hello, world!')
|
25
|
+
|
26
|
+
## References
|
27
|
+
|
28
|
+
* Based on [typography-helper][2]
|
29
|
+
* ...and on [Typogrify][3]
|
30
|
+
* [Description of typogrify][1]
|
31
|
+
|
32
|
+
[1]: http://jeffcroft.com/blog/2007/may/29/typogrify-easily-produce-web-typography-doesnt-suc/
|
33
|
+
[2]: http://github.com/hunter/typography-helper
|
34
|
+
[3]: http://code.google.com/p/typogrify
|
35
|
+
|
36
|
+
## Note on Patches/Pull Requests
|
37
|
+
|
38
|
+
* Fork the project.
|
39
|
+
* Make your feature addition or bug fix.
|
40
|
+
* Add tests for it. This is important so I don't break it in a
|
41
|
+
future version unintentionally.
|
42
|
+
* Commit, do not mess with rakefile, version, or history.
|
43
|
+
(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)
|
44
|
+
* Send me a pull request. Bonus points for topic branches.
|
45
|
+
|
46
|
+
## License
|
47
|
+
|
48
|
+
Copyright (c) 2010 Arjan van der Gaag
|
49
|
+
|
50
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
51
|
+
a copy of this software and associated documentation files (the
|
52
|
+
"Software"), to deal in the Software without restriction, including
|
53
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
54
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
55
|
+
permit persons to whom the Software is furnished to do so, subject to
|
56
|
+
the following conditions:
|
57
|
+
|
58
|
+
The above copyright notice and this permission notice shall be
|
59
|
+
included in all copies or substantial portions of the Software.
|
60
|
+
|
61
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
62
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
63
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
64
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
65
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
66
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
67
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "typogruby"
|
8
|
+
gem.summary = %Q{Improves web typography like Django's Typogrify}
|
9
|
+
gem.description = %Q{Improve web typography using various text filters. This gem prevents widows and applies markup to ampersans, consecutive capitals and initial quotes.}
|
10
|
+
gem.email = "arjan@arjanvandergaag.nl"
|
11
|
+
gem.homepage = "http://avdgaag.github.com/typogruby"
|
12
|
+
gem.authors = ["Arjan van der Gaag"]
|
13
|
+
gem.add_development_dependency "yard", ">= 0"
|
14
|
+
gem.add_dependency "rubypants", ">= 0"
|
15
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
16
|
+
end
|
17
|
+
Jeweler::GemcutterTasks.new
|
18
|
+
rescue LoadError
|
19
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
20
|
+
end
|
21
|
+
|
22
|
+
require 'rake/testtask'
|
23
|
+
Rake::TestTask.new(:test) do |test|
|
24
|
+
test.libs << 'lib' << 'test'
|
25
|
+
test.pattern = 'test/**/test_*.rb'
|
26
|
+
test.verbose = true
|
27
|
+
end
|
28
|
+
|
29
|
+
begin
|
30
|
+
require 'rcov/rcovtask'
|
31
|
+
Rcov::RcovTask.new do |test|
|
32
|
+
test.libs << 'test'
|
33
|
+
test.pattern = 'test/**/test_*.rb'
|
34
|
+
test.verbose = true
|
35
|
+
end
|
36
|
+
rescue LoadError
|
37
|
+
task :rcov do
|
38
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
task :test => :check_dependencies
|
43
|
+
|
44
|
+
task :default => :test
|
45
|
+
|
46
|
+
begin
|
47
|
+
require 'yard'
|
48
|
+
YARD::Rake::YardocTask.new
|
49
|
+
rescue LoadError
|
50
|
+
task :yardoc do
|
51
|
+
abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
|
52
|
+
end
|
53
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.0
|
data/lib/typogruby.rb
ADDED
@@ -0,0 +1,173 @@
|
|
1
|
+
require 'rubypants'
|
2
|
+
|
3
|
+
# A collection of simple helpers for improving web
|
4
|
+
# typograhy. Based on TypographyHelper by Luke Hartman and Typogrify.
|
5
|
+
#
|
6
|
+
# @see http://github.com/hunter/typography-helper
|
7
|
+
# @see http://code.google.com/p/typogrify
|
8
|
+
# @author Arjan van der Gaag <arjan.vandergaag@gmail.com>
|
9
|
+
module Typogruby
|
10
|
+
|
11
|
+
# Get the current gem version number
|
12
|
+
# @return [String]
|
13
|
+
def version
|
14
|
+
File.read(File.join(File.dirname(__FILE__), *%w{.. VERSION}))
|
15
|
+
end
|
16
|
+
|
17
|
+
# Applies smartypants to a given piece of text
|
18
|
+
#
|
19
|
+
# @example
|
20
|
+
# smartypants('The "Green" man')
|
21
|
+
# # => 'The “Green” man'
|
22
|
+
#
|
23
|
+
# @param [String] text input text
|
24
|
+
# @return [String] input text with smartypants applied
|
25
|
+
def smartypants(text)
|
26
|
+
::RubyPants.new(text).to_html
|
27
|
+
end
|
28
|
+
|
29
|
+
# converts a & surrounded by optional whitespace or a non-breaking space
|
30
|
+
# to the HTML entity and surrounds it in a span with a styled class
|
31
|
+
#
|
32
|
+
# @example
|
33
|
+
# amp('One & two')
|
34
|
+
# # => 'One <span class="amp">&</span> two'
|
35
|
+
# amp('One & two')
|
36
|
+
# # => 'One <span class="amp">&</span> two'
|
37
|
+
# amp('One & two')
|
38
|
+
# # => 'One <span class="amp">&</span> two'
|
39
|
+
# amp('One & two')
|
40
|
+
# # => 'One <span class="amp">&</span> two'
|
41
|
+
#
|
42
|
+
# @example It won't mess up & that are already wrapped, in entities or URLs
|
43
|
+
#
|
44
|
+
# amp('One <span class="amp">&</span> two')
|
45
|
+
# # => 'One <span class="amp">&</span> two'
|
46
|
+
# amp('“this” & <a href="/?that&test">that</a>')
|
47
|
+
# # => '“this” <span class="amp">&</span> <a href="/?that&test">that</a>'
|
48
|
+
#
|
49
|
+
# @example It should ignore standalone amps that are in attributes
|
50
|
+
# amp('<link href="xyz.html" title="One & Two">xyz</link>')
|
51
|
+
# # => '<link href="xyz.html" title="One & Two">xyz</link>'
|
52
|
+
#
|
53
|
+
# @param [String] text input text
|
54
|
+
# @return [String] input text with ampersands wrapped
|
55
|
+
def amp(text)
|
56
|
+
# $1 is an excluded HTML tag, $2 is the part before the caps and $3 is the amp match
|
57
|
+
text.gsub(/<(code|pre).+?<\/\1>|(\s| )&(?:amp;|#38;)?(\s| )/) {|str|
|
58
|
+
$1 ? str : $2 + '<span class="amp">&</span>' + $3 }.gsub(/(\w+)="(.*?)<span class="amp">&<\/span>(.*?)"/, '\1="\2&\3"')
|
59
|
+
end
|
60
|
+
|
61
|
+
# replaces space(s) before the last word (or tag before the last word)
|
62
|
+
# before an optional closing element (<tt>a</tt>, <tt>em</tt>,
|
63
|
+
# <tt>span</tt>, strong) before a closing tag (<tt>p</tt>, <tt>h[1-6]</tt>,
|
64
|
+
# <tt>li</tt>, <tt>dt</tt>, <tt>dd</tt>) or the end of the string
|
65
|
+
#
|
66
|
+
# @example
|
67
|
+
# > widont('A very simple test')
|
68
|
+
# # => 'A very simple test'
|
69
|
+
#
|
70
|
+
# @example Single word items shouldn't be changed
|
71
|
+
# widont('Test')
|
72
|
+
# # => 'Test'
|
73
|
+
# widont(' Test')
|
74
|
+
# # => ' Test'
|
75
|
+
# widont('<ul><li>Test</p></li><ul>')
|
76
|
+
# # => '<ul><li>Test</p></li><ul>'
|
77
|
+
# widont('<ul><li> Test</p></li><ul>')
|
78
|
+
# # => '<ul><li> Test</p></li><ul>'
|
79
|
+
#
|
80
|
+
# @example Nested tags
|
81
|
+
# widont('<p>In a couple of paragraphs</p><p>paragraph two</p>')
|
82
|
+
# # => '<p>In a couple of paragraphs</p><p>paragraph two</p>'
|
83
|
+
# widont('<h1><a href="#">In a link inside a heading</i> </a></h1>')
|
84
|
+
# # => '<h1><a href="#">In a link inside a heading</i> </a></h1>'
|
85
|
+
# widont('<h1><a href="#">In a link</a> followed by other text</h1>')
|
86
|
+
# # => '<h1><a href="#">In a link</a> followed by other text</h1>'
|
87
|
+
#
|
88
|
+
# @example Empty HTMLs shouldn't error
|
89
|
+
# widont('<h1><a href="#"></a></h1>')
|
90
|
+
# # => '<h1><a href="#"></a></h1>'
|
91
|
+
#
|
92
|
+
# @example Excluded tags
|
93
|
+
# widont('<div>Divs get no love!</div>')
|
94
|
+
# # => '<div>Divs get no love!</div>'
|
95
|
+
# widont('<pre>Neither do PREs</pre>')
|
96
|
+
# # => '<pre>Neither do PREs</pre>'
|
97
|
+
# widont('<div><p>But divs with paragraphs do!</p></div>')
|
98
|
+
# # => '<div><p>But divs with paragraphs do!</p></div>'
|
99
|
+
#
|
100
|
+
# @see http://mucur.name/posts/widon-t-and-smartypants-helpers-for-rails
|
101
|
+
# @see http://shauninman.com/archive/2006/08/22/widont_wordpress_plugin
|
102
|
+
# @param [String] text input text
|
103
|
+
# @return [String] input text with non-breaking spaces inserted
|
104
|
+
def widont(text)
|
105
|
+
text.gsub(%r{
|
106
|
+
((?:</?(?:a|em|span|strong|i|b)[^>]*>)|[^<>\s]) # must be proceeded by an approved inline opening or closing tag or a nontag/nonspace
|
107
|
+
\s+ # the space to replace
|
108
|
+
([^<>\s]+ # must be flollowed by non-tag non-space characters
|
109
|
+
\s* # optional white space!
|
110
|
+
(</(a|em|span|strong|i|b)>\s*)* # optional closing inline tags with optional white space after each
|
111
|
+
((</(p|h[1-6]|li|dt|dd)>)|$)) # end with a closing p, h1-6, li or the end of the string
|
112
|
+
}x, '\1 \2')
|
113
|
+
end
|
114
|
+
|
115
|
+
# surrounds two or more consecutive captial letters, perhaps with interspersed digits and periods
|
116
|
+
# in a span with a styled class
|
117
|
+
#
|
118
|
+
# @example
|
119
|
+
# caps("A message from KU")
|
120
|
+
# # => 'A message from <span class="caps">KU</span>'
|
121
|
+
#
|
122
|
+
# @example Allows digits
|
123
|
+
# caps("A message from 2KU2 with digits")
|
124
|
+
# # => 'A message from <span class="caps">2KU2</span> with digits'
|
125
|
+
#
|
126
|
+
# @example All caps with with apostrophes in them shouldn't break. Only handles dump apostrophes though.
|
127
|
+
# caps("JIMMY'S")
|
128
|
+
# # => '<span class="caps">JIMMY\\'S</span>'
|
129
|
+
# caps("<i>D.O.T.</i>HE34T<b>RFID</b>")
|
130
|
+
# # => '<i><span class="caps">D.O.T.</span></i><span class="caps">HE34T</span><b><span class="caps">RFID</span></b>'
|
131
|
+
#
|
132
|
+
# @param [String] text input text
|
133
|
+
# @return [String] input text with caps wrapped
|
134
|
+
def caps(text)
|
135
|
+
# $1 is an excluded HTML tag, $2 is the part before the caps and $3 is the caps match
|
136
|
+
text.gsub(/<(code|pre).+?<\/\1>|(\s| |^|'|"|>)([A-Z\d][A-Z\d\.']{1,})(?!\w)/) {|str|
|
137
|
+
$1 ? str : $2 + '<span class="caps">' + $3 + '</span>' }
|
138
|
+
end
|
139
|
+
|
140
|
+
# encloses initial single or double quote, or their entities
|
141
|
+
# (optionally preceeded by a block element and perhaps an inline element)
|
142
|
+
# with a span that can be styled
|
143
|
+
#
|
144
|
+
# @example
|
145
|
+
# initial_quotes('"With primes"')
|
146
|
+
# # => '<span class="dquo">"</span>With primes"'
|
147
|
+
# initial_quotes("'With single primes'")
|
148
|
+
# # => '<span class="quo">\\'</span>With single primes\\''
|
149
|
+
#
|
150
|
+
# @example With primes and links
|
151
|
+
# initial_quotes('<a href="#">"With primes and a link"</a>')
|
152
|
+
# # => '<a href="#"><span class="dquo">"</span>With primes and a link"</a>'
|
153
|
+
#
|
154
|
+
# @example with Smartypants-quotes
|
155
|
+
# initial_quotes('“With smartypanted quotes”')
|
156
|
+
# # => '<span class="dquo">“</span>With smartypanted quotes”'
|
157
|
+
#
|
158
|
+
# @param [String] text input text
|
159
|
+
# @return [String] input text with initial quotes wrapped
|
160
|
+
def initial_quotes(text)
|
161
|
+
# $1 is the initial part of the string, $2 is the quote or entitity, and $3 is the double quote
|
162
|
+
text.gsub(/((?:<(?:h[1-6]|p|li|dt|dd)[^>]*>|^)\s*(?:<(?:a|em|strong|span)[^>]*>)?)('|‘|("|“))/) {$1 + "<span class=\"#{'d' if $3}quo\">#{$2}</span>"}
|
163
|
+
end
|
164
|
+
|
165
|
+
# main function to do all the functions from the method
|
166
|
+
# @param [String] text input text
|
167
|
+
# @return [String] input text with all filters applied
|
168
|
+
def improve(text)
|
169
|
+
initial_quotes(caps(smartypants(widont(amp(text)))))
|
170
|
+
end
|
171
|
+
|
172
|
+
extend self
|
173
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestTypogruby < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def test_should_replace_amps
|
6
|
+
assert_equal 'One <span class="amp">&</span> two', amp('One & two')
|
7
|
+
assert_equal 'One <span class="amp">&</span> two', amp('One & two')
|
8
|
+
assert_equal 'One <span class="amp">&</span> two', amp('One & two')
|
9
|
+
assert_equal 'One <span class="amp">&</span> two', amp('One & two')
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_should_ignore_special_amps
|
13
|
+
assert_equal 'One <span class="amp">&</span> two', amp('One <span class="amp">&</span> two')
|
14
|
+
assert_equal '“this” <span class="amp">&</span> <a href="/?that&test">that</a>', amp('“this” & <a href="/?that&test">that</a>')
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_should_ignore_standalone_amps_in_attributes
|
18
|
+
assert_equal '<link href="xyz.html" title="One & Two">xyz</link>', amp('<link href="xyz.html" title="One & Two">xyz</link>')
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_should_replace_caps
|
22
|
+
assert_equal 'A message from <span class="caps">KU</span>', caps("A message from KU")
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_should_ignore_special_case_caps
|
26
|
+
assert_equal '<pre>CAPS</pre> more <span class="caps">CAPS</span>', caps("<pre>CAPS</pre> more CAPS")
|
27
|
+
assert_equal 'A message from <span class="caps">2KU2</span> with digits', caps("A message from 2KU2 with digits")
|
28
|
+
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.")
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_should_not_break_caps_with_apostrophes
|
32
|
+
assert_equal '<span class="caps">JIMMY\'S</span>', caps("JIMMY'S")
|
33
|
+
assert_equal '<i><span class="caps">D.O.T.</span></i><span class="caps">HE34T</span><b><span class="caps">RFID</span></b>', caps("<i>D.O.T.</i>HE34T<b>RFID</b>")
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_should_replace_quotes
|
37
|
+
assert_equal '<span class="dquo">"</span>With primes"', initial_quotes('"With primes"')
|
38
|
+
assert_equal '<span class="quo">\'</span>With single primes\'', initial_quotes("'With single primes'")
|
39
|
+
assert_equal '<a href="#"><span class="dquo">"</span>With primes and a link"</a>', initial_quotes('<a href="#">"With primes and a link"</a>')
|
40
|
+
assert_equal '<span class="dquo">“</span>With smartypanted quotes”', initial_quotes('“With smartypanted quotes”')
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_should_apply_smartypants
|
44
|
+
assert_equal 'The “Green” man', smartypants('The "Green" man')
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_should_apply_all_filters
|
48
|
+
assert_equal '<h2><span class="dquo">“</span>Jayhawks” <span class="amp">&</span> <span class="caps">KU</span> fans act extremely obnoxiously</h2>', improve('<h2>"Jayhawks" & KU fans act extremely obnoxiously</h2>')
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_should_prevent_widows
|
52
|
+
assert_equal 'A very simple test', widont('A very simple test')
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_should_not_change_single_word_items
|
56
|
+
assert_equal 'Test', widont('Test')
|
57
|
+
assert_equal ' Test', widont(' Test')
|
58
|
+
assert_equal '<ul><li>Test</p></li><ul>', widont('<ul><li>Test</p></li><ul>')
|
59
|
+
assert_equal '<ul><li> Test</p></li><ul>', widont('<ul><li> Test</p></li><ul>')
|
60
|
+
assert_equal '<p>In a couple of paragraphs</p><p>paragraph two</p>', widont('<p>In a couple of paragraphs</p><p>paragraph two</p>')
|
61
|
+
assert_equal '<h1><a href="#">In a link inside a heading</i> </a></h1>', widont('<h1><a href="#">In a link inside a heading</i> </a></h1>')
|
62
|
+
assert_equal '<h1><a href="#">In a link</a> followed by other text</h1>', widont('<h1><a href="#">In a link</a> followed by other text</h1>')
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_should_not_error_on_empty_html
|
66
|
+
assert_equal '<h1><a href="#"></a></h1>', widont('<h1><a href="#"></a></h1>')
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_should_ignore_widows_in_special_tags
|
70
|
+
assert_equal '<div>Divs get no love!</div>', widont('<div>Divs get no love!</div>')
|
71
|
+
assert_equal '<pre>Neither do PREs</pre>', widont('<pre>Neither do PREs</pre>')
|
72
|
+
assert_equal '<div><p>But divs with paragraphs do!</p></div>', widont('<div><p>But divs with paragraphs do!</p></div>')
|
73
|
+
end
|
74
|
+
end
|
data/typogrify.gemspec
ADDED
@@ -0,0 +1,56 @@
|
|
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{typogrify}
|
8
|
+
s.version = "1.0.0"
|
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{2010-07-26}
|
13
|
+
s.description = %q{Improve web typography using various text filters. This gem prevents widows and applies markup to ampersans, consecutive capitals and initial quotes.}
|
14
|
+
s.email = %q{arjan@arjanvandergaag.nl}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.md"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"LICENSE",
|
23
|
+
"README.md",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"lib/typogrify.rb",
|
27
|
+
"test/helper.rb",
|
28
|
+
"test/test_typogrify.rb"
|
29
|
+
]
|
30
|
+
s.homepage = %q{http://avdgaag.github.com/typogrify}
|
31
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
32
|
+
s.require_paths = ["lib"]
|
33
|
+
s.rubygems_version = %q{1.3.7}
|
34
|
+
s.summary = %q{Improves web typography like Django's Typogrify}
|
35
|
+
s.test_files = [
|
36
|
+
"test/helper.rb",
|
37
|
+
"test/test_typogrify.rb"
|
38
|
+
]
|
39
|
+
|
40
|
+
if s.respond_to? :specification_version then
|
41
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
42
|
+
s.specification_version = 3
|
43
|
+
|
44
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
45
|
+
s.add_development_dependency(%q<yard>, [">= 0"])
|
46
|
+
s.add_runtime_dependency(%q<rubypants>, [">= 0"])
|
47
|
+
else
|
48
|
+
s.add_dependency(%q<yard>, [">= 0"])
|
49
|
+
s.add_dependency(%q<rubypants>, [">= 0"])
|
50
|
+
end
|
51
|
+
else
|
52
|
+
s.add_dependency(%q<yard>, [">= 0"])
|
53
|
+
s.add_dependency(%q<rubypants>, [">= 0"])
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
metadata
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: typogruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 1.0.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Arjan van der Gaag
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-07-26 00:00:00 +02:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: yard
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rubypants
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
47
|
+
type: :runtime
|
48
|
+
version_requirements: *id002
|
49
|
+
description: Improve web typography using various text filters. This gem prevents widows and applies markup to ampersans, consecutive capitals and initial quotes.
|
50
|
+
email: arjan@arjanvandergaag.nl
|
51
|
+
executables: []
|
52
|
+
|
53
|
+
extensions: []
|
54
|
+
|
55
|
+
extra_rdoc_files:
|
56
|
+
- LICENSE
|
57
|
+
- README.md
|
58
|
+
files:
|
59
|
+
- .document
|
60
|
+
- .gitignore
|
61
|
+
- LICENSE
|
62
|
+
- README.md
|
63
|
+
- Rakefile
|
64
|
+
- VERSION
|
65
|
+
- lib/typogruby.rb
|
66
|
+
- test/helper.rb
|
67
|
+
- test/test_typogruby.rb
|
68
|
+
- typogrify.gemspec
|
69
|
+
has_rdoc: true
|
70
|
+
homepage: http://avdgaag.github.com/typogruby
|
71
|
+
licenses: []
|
72
|
+
|
73
|
+
post_install_message:
|
74
|
+
rdoc_options:
|
75
|
+
- --charset=UTF-8
|
76
|
+
require_paths:
|
77
|
+
- lib
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
hash: 3
|
84
|
+
segments:
|
85
|
+
- 0
|
86
|
+
version: "0"
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
hash: 3
|
93
|
+
segments:
|
94
|
+
- 0
|
95
|
+
version: "0"
|
96
|
+
requirements: []
|
97
|
+
|
98
|
+
rubyforge_project:
|
99
|
+
rubygems_version: 1.3.7
|
100
|
+
signing_key:
|
101
|
+
specification_version: 3
|
102
|
+
summary: Improves web typography like Django's Typogrify
|
103
|
+
test_files:
|
104
|
+
- test/helper.rb
|
105
|
+
- test/test_typogruby.rb
|