bb-ruby 0.8.4 → 0.8.5
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/lib/bb-ruby.rb +5 -3
- data/test/test_bb-ruby.rb +18 -6
- metadata +3 -3
data/lib/bb-ruby.rb
CHANGED
@@ -2,7 +2,7 @@ $:.unshift(File.dirname(__FILE__)) unless
|
|
2
2
|
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
3
|
|
4
4
|
module BBRuby
|
5
|
-
VERSION = '0.8.
|
5
|
+
VERSION = '0.8.5'
|
6
6
|
|
7
7
|
# allowable image formats
|
8
8
|
@@imageformats = 'png|bmp|jpg|gif|jpeg'
|
@@ -242,8 +242,10 @@ module BBRuby
|
|
242
242
|
#
|
243
243
|
def to_html(text, tags_alternative_definition = {}, escape_html=true, method=:disable, *tags)
|
244
244
|
text = text.clone
|
245
|
+
|
245
246
|
# escape < and > to remove any html
|
246
|
-
if escape_html
|
247
|
+
if escape_html
|
248
|
+
text.gsub!( '&', '&' )
|
247
249
|
text.gsub!( '<', '<' )
|
248
250
|
text.gsub!( '>', '>' )
|
249
251
|
end
|
@@ -261,7 +263,7 @@ module BBRuby
|
|
261
263
|
|
262
264
|
# parse spacing
|
263
265
|
text.gsub!( /\r\n?/, "\n" )
|
264
|
-
text.gsub!( /\n/, "<br
|
266
|
+
text.gsub!( /\n/, "<br />\n" )
|
265
267
|
|
266
268
|
# return markup
|
267
269
|
text
|
data/test/test_bb-ruby.rb
CHANGED
@@ -7,20 +7,20 @@ class TestBBRuby < Test::Unit::TestCase
|
|
7
7
|
def test_strong
|
8
8
|
assert_equal '<strong>simple</strong>', '[b]simple[/b]'.bbcode_to_html
|
9
9
|
assert_equal '<strong>simple</strong>', '[b:7a9ca2c5c3]simple[/b:7a9ca2c5c3]'.bbcode_to_html
|
10
|
-
assert_equal "<strong>line 1<br
|
11
|
-
assert_equal
|
10
|
+
assert_equal "<strong>line 1<br />\nline 2</strong>", "[b:7a9ca2c5c3]line 1\nline 2[/b:7a9ca2c5c3]".bbcode_to_html
|
11
|
+
assert_equal "<strong>1. text 1:</strong> text 2<br />\n<strong>2. text 3</strong>", "[b:post_uid0]1. text 1:[/b:post_uid0] text 2\n[b:post_uid0]2. text 3[/b:post_uid0]".bbcode_to_html
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_em
|
15
15
|
assert_equal '<em>simple</em>', '[i]simple[/i]'.bbcode_to_html
|
16
16
|
assert_equal '<em>simple</em>', '[i:7a9ca2c5c3]simple[/i:7a9ca2c5c3]'.bbcode_to_html
|
17
|
-
assert_equal "<em>line 1<br
|
17
|
+
assert_equal "<em>line 1<br />\nline 2</em>", "[i:7a9ca2c5c3]line 1\nline 2[/i:7a9ca2c5c3]".bbcode_to_html
|
18
18
|
end
|
19
19
|
|
20
20
|
def test_u
|
21
21
|
assert_equal '<u>simple</u>', '[u]simple[/u]'.bbcode_to_html
|
22
22
|
assert_equal '<u>simple</u>', '[u:7a9ca2c5c3]simple[/u:7a9ca2c5c3]'.bbcode_to_html
|
23
|
-
assert_equal "<u>line 1<br
|
23
|
+
assert_equal "<u>line 1<br />\nline 2</u>", "[u:7a9ca2c5c3]line 1\nline 2[/u:7a9ca2c5c3]".bbcode_to_html
|
24
24
|
end
|
25
25
|
|
26
26
|
def test_del
|
@@ -38,7 +38,7 @@ class TestBBRuby < Test::Unit::TestCase
|
|
38
38
|
def test_code
|
39
39
|
assert_equal '<code>simple</code>', '[code]simple[/code]'.bbcode_to_html
|
40
40
|
assert_equal '<code>simple</code>', '[code:7a9ca2c5c3]simple[/code:7a9ca2c5c3]'.bbcode_to_html
|
41
|
-
assert_equal "<code>var bxi = 0;<br
|
41
|
+
assert_equal "<code>var bxi = 0;<br />\n//Holds current speed of scrolling menu</code>", "[code:1:91cbdd72b7]var bxi = 0;\n//Holds current speed of scrolling menu[/code:1:91cbdd72b7]".bbcode_to_html
|
42
42
|
end
|
43
43
|
|
44
44
|
def test_size
|
@@ -113,7 +113,7 @@ class TestBBRuby < Test::Unit::TestCase
|
|
113
113
|
assert_equal '<a href="http://google.com">Google</a>', '[url=http://google.com]Google[/url]'.bbcode_to_html
|
114
114
|
assert_equal '<a href="http://google.com">http://google.com</a>', '[url]http://google.com[/url]'.bbcode_to_html
|
115
115
|
assert_equal '<a href="http://www.altctrlsupr.com/dmstk/kdd070803/00.html"> ABRIR ALBUM </a>','[URL=http://www.altctrlsupr.com/dmstk/kdd070803/00.html] ABRIR ALBUM [/URL]'.bbcode_to_html
|
116
|
-
assert_equal
|
116
|
+
assert_equal %Q(<a href="http://www.altctrlsupr.com/dmstk/kdd070803/00.html"> ABRIR<br />\nALBUM </a>),"[URL=http://www.altctrlsupr.com/dmstk/kdd070803/00.html] ABRIR\nALBUM [/URL]".bbcode_to_html
|
117
117
|
assert_equal '<a href="http://www.urimalet.com/cadaverex.mp3">aha</a>', "[URL=http://www.urimalet.com/cadaverex.mp3]aha[/URL]".bbcode_to_html
|
118
118
|
end
|
119
119
|
|
@@ -208,4 +208,16 @@ class TestBBRuby < Test::Unit::TestCase
|
|
208
208
|
assert_equal "<strong>bold</strong><em>italic</em><u>underline</u><fieldset><blockquote>quote</blockquote></fieldset><a href=\"foobar\">link</a>", "[b]bold[/b][i]italic[/i][u]underline[/u][quote]quote[/quote][url=foobar]link[/url]".bbcode_to_html({}, true, :enable, :bold, :italics, :underline, :link, :quote)
|
209
209
|
end
|
210
210
|
|
211
|
+
def test_no_ending_tag
|
212
|
+
assert_equal "this [b]should not be bold", "this [b]should not be bold".bbcode_to_html
|
213
|
+
end
|
214
|
+
|
215
|
+
def test_no_start_tag
|
216
|
+
assert_equal "this should not be bold[/b]", "this should not be bold[/b]".bbcode_to_html
|
217
|
+
end
|
218
|
+
|
219
|
+
def test_different_start_and_ending_tags
|
220
|
+
assert_equal "this [b]should not do formatting[/i]", "this [b]should not do formatting[/i]".bbcode_to_html
|
221
|
+
end
|
222
|
+
|
211
223
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bb-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Craig P Jolicoeur
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-05-21 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 1.
|
23
|
+
version: 1.4.1
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: hoe
|