typogruby 1.0.0 → 1.0.1
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/VERSION +1 -1
- data/lib/typogruby.rb +10 -2
- data/test/test_typogruby.rb +1 -0
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.1
|
data/lib/typogruby.rb
CHANGED
@@ -133,8 +133,16 @@ module Typogruby
|
|
133
133
|
# @return [String] input text with caps wrapped
|
134
134
|
def caps(text)
|
135
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)/)
|
137
|
-
|
136
|
+
text.gsub(/<(code|pre).+?<\/\1>|(\s| |^|'|"|>)([A-Z\d][A-Z\d\.']{1,})(?!\w)/) do |str|
|
137
|
+
excluded, before, caps = $1, $2, $3
|
138
|
+
if excluded
|
139
|
+
str
|
140
|
+
elsif $3 =~ /^\d+$/
|
141
|
+
before + caps
|
142
|
+
else
|
143
|
+
before + '<span class="caps">' + caps + '</span>'
|
144
|
+
end
|
145
|
+
end
|
138
146
|
end
|
139
147
|
|
140
148
|
# encloses initial single or double quote, or their entities
|
data/test/test_typogruby.rb
CHANGED
@@ -23,6 +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
27
|
assert_equal '<pre>CAPS</pre> more <span class="caps">CAPS</span>', caps("<pre>CAPS</pre> more CAPS")
|
27
28
|
assert_equal 'A message from <span class="caps">2KU2</span> with digits', caps("A message from 2KU2 with digits")
|
28
29
|
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.")
|
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: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 1
|
10
|
+
version: 1.0.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Arjan van der Gaag
|