typogruby 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +5 -0
- data/VERSION +1 -1
- data/lib/typogruby.rb +3 -3
- data/test/test_typogruby.rb +5 -1
- metadata +4 -4
data/README.md
CHANGED
@@ -47,6 +47,11 @@ This will output the contents of your file with all filters applied. Use `typogr
|
|
47
47
|
|
48
48
|
## Changelog
|
49
49
|
|
50
|
+
### 1.0.4
|
51
|
+
|
52
|
+
* Bugfix: no longer regard combination of digits and periods as caps.
|
53
|
+
* Bugfix: do not add consecutive non-breaking spaces to prevent widows
|
54
|
+
|
50
55
|
### 1.0.3
|
51
56
|
|
52
57
|
* Bugfix: caps also ignores unequal but same excepted tags
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.4
|
data/lib/typogruby.rb
CHANGED
@@ -105,11 +105,11 @@ module Typogruby
|
|
105
105
|
text.gsub(%r{
|
106
106
|
((?:</?(?:a|em|span|strong|i|b)[^>]*>)|[^<>\s]) # must be proceeded by an approved inline opening or closing tag or a nontag/nonspace
|
107
107
|
\s+ # the space to replace
|
108
|
-
([^<>\s]+
|
108
|
+
(([^<>\s]+) # must be flollowed by non-tag non-space characters
|
109
109
|
\s* # optional white space!
|
110
110
|
(</(a|em|span|strong|i|b)>\s*)* # optional closing inline tags with optional white space after each
|
111
111
|
((</(p|h[1-6]|li|dt|dd)>)|$)) # end with a closing p, h1-6, li or the end of the string
|
112
|
-
}x
|
112
|
+
}x) { |match| $1 + (match.include?(' ') ? ' ' : ' ') + $2 } # Make sure to not add another nbsp before one already there
|
113
113
|
end
|
114
114
|
|
115
115
|
# surrounds two or more consecutive captial letters, perhaps with interspersed digits and periods
|
@@ -137,7 +137,7 @@ module Typogruby
|
|
137
137
|
excluded, before, caps = $1, $2, $3
|
138
138
|
if excluded
|
139
139
|
str
|
140
|
-
elsif $3 =~
|
140
|
+
elsif $3 =~ /^[\d\.]+$/
|
141
141
|
before + caps
|
142
142
|
else
|
143
143
|
before + '<span class="caps">' + caps + '</span>'
|
data/test/test_typogruby.rb
CHANGED
@@ -23,7 +23,7 @@ class TestTypogruby < Test::Unit::TestCase
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_should_ignore_special_case_caps
|
26
|
-
assert_equal 'It should ignore just numbers like 1234', caps('It should ignore just numbers like 1234')
|
26
|
+
assert_equal 'It should ignore just numbers like 1234.', caps('It should ignore just numbers like 1234.')
|
27
27
|
assert_equal '<pre>CAPS</pre> more <span class="caps">CAPS</span>', caps("<pre>CAPS</pre> more CAPS")
|
28
28
|
assert_equal '<Pre>CAPS</PRE> with odd tag names <span class="caps">CAPS</span>', caps("<Pre>CAPS</PRE> with odd tag names CAPS")
|
29
29
|
assert_equal 'A message from <span class="caps">2KU2</span> with digits', caps("A message from 2KU2 with digits")
|
@@ -65,6 +65,10 @@ class TestTypogruby < Test::Unit::TestCase
|
|
65
65
|
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>')
|
66
66
|
end
|
67
67
|
|
68
|
+
def test_should_not_add_nbsp_before_another
|
69
|
+
assert_equal 'Sentence with one nbsp', widont('Sentence with one nbsp')
|
70
|
+
end
|
71
|
+
|
68
72
|
def test_should_not_error_on_empty_html
|
69
73
|
assert_equal '<h1><a href="#"></a></h1>', widont('<h1><a href="#"></a></h1>')
|
70
74
|
end
|
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: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 4
|
10
|
+
version: 1.0.4
|
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-07-
|
18
|
+
date: 2010-07-28 00:00:00 +02:00
|
19
19
|
default_executable: typogruby
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|