cpjolicoeur-bb-ruby 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +1 -2
- data/bb-ruby.gemspec +2 -2
- data/lib/bb-ruby.rb +6 -8
- data/test/test-bb-ruby.rb +15 -0
- metadata +2 -2
data/README.markdown
CHANGED
@@ -89,9 +89,8 @@ The following is the list of BBCode tags processed by BBRuby and their associate
|
|
89
89
|
* [img size=] :image
|
90
90
|
* [img=] :image
|
91
91
|
* [img] :image
|
92
|
-
* [youtube?v=] :video
|
93
92
|
* [youtube] :video
|
94
|
-
* [gvideo
|
93
|
+
* [gvideo] :video
|
95
94
|
* [email] :email
|
96
95
|
|
97
96
|
## Developers
|
data/bb-ruby.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "bb-ruby"
|
3
|
-
s.version = "0.8.
|
4
|
-
s.date = "2008-11-
|
3
|
+
s.version = "0.8.1"
|
4
|
+
s.date = "2008-11-25"
|
5
5
|
s.summary = "BBCode conversion library for Ruby"
|
6
6
|
s.email = "cpjolicoeur@gmail.com"
|
7
7
|
s.homepage = "http://github.com/cpjolicoeur/bb-ruby"
|
data/lib/bb-ruby.rb
CHANGED
@@ -80,7 +80,7 @@ module BBRuby
|
|
80
80
|
/\[\*(:[^\[]+)?\]([^(\[|\<)]+)/mi,
|
81
81
|
'<li>\2</li>',
|
82
82
|
'List item (alternative)',
|
83
|
-
|
83
|
+
'[*]list item',
|
84
84
|
:listitem],
|
85
85
|
'Unordered list (alternative)' => [
|
86
86
|
/\[list(:.*)?\]((?:(?!list).)*)\[\/list(:.)?\1?\]/mi,
|
@@ -110,38 +110,37 @@ module BBRuby
|
|
110
110
|
/\[dt\](.*?)\[\/dt\]/mi,
|
111
111
|
'<dt>\1</dt>',
|
112
112
|
'List of definition terms',
|
113
|
-
|
113
|
+
'[dt]definition term[/dt]',
|
114
114
|
:defineterm],
|
115
115
|
'Definition Definition' => [
|
116
116
|
/\[dd\](.*?)\[\/dd\]/mi,
|
117
117
|
'<dd>\1</dd>',
|
118
118
|
'Definition definitions',
|
119
|
-
|
119
|
+
'[dd]my definition[/dd',
|
120
120
|
:definition],
|
121
121
|
'Quote' => [
|
122
122
|
/\[quote(:.*)?="?(.*?)"?\](.*?)\[\/quote\1?\]/mi,
|
123
123
|
'<fieldset><legend>\2</legend><blockquote>\3</blockquote></fieldset>',
|
124
124
|
'Quote with citation',
|
125
|
-
|
125
|
+
"[quote=mike]Now is the time...[/quote]",
|
126
126
|
:quote],
|
127
127
|
'Quote (Sourceless)' => [
|
128
128
|
/\[quote(:.*)?\](.*?)\[\/quote\1?\]/mi,
|
129
129
|
'<fieldset><blockquote>\2</blockquote></fieldset>',
|
130
130
|
'Quote (sourceclass)',
|
131
|
-
|
131
|
+
"[quote]Now is the time...[/quote]",
|
132
132
|
:quote],
|
133
133
|
'Link' => [
|
134
134
|
/\[url=(.*?)\](.*?)\[\/url\]/mi,
|
135
135
|
'<a href="\1">\2</a>',
|
136
136
|
'Hyperlink to somewhere else',
|
137
137
|
'Maybe try looking on [url=http://google.com]Google[/url]?',
|
138
|
-
nil, nil,
|
139
138
|
:link],
|
140
139
|
'Link (Implied)' => [
|
141
140
|
/\[url\](.*?)\[\/url\]/mi,
|
142
141
|
'<a href="\1">\1</a>',
|
143
142
|
'Hyperlink (implied)',
|
144
|
-
|
143
|
+
"Maybe try looking on [url]http://google.com[/url]",
|
145
144
|
:link],
|
146
145
|
#
|
147
146
|
# TODO: fix automatic links
|
@@ -170,7 +169,6 @@ module BBRuby
|
|
170
169
|
'Display an image',
|
171
170
|
'Check out this crazy cat: [img]http://catsweekly.com/crazycat.jpg[/img]',
|
172
171
|
:image],
|
173
|
-
|
174
172
|
'YouTube' => [
|
175
173
|
/\[youtube\](.*?)\?v=([\w\d\-]+).*\[\/youtube\]/im,
|
176
174
|
'<object width="400" height="330"><param name="movie" value="http://www.youtube.com/v/\2"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/\2" type="application/x-shockwave-flash" wmode="transparent" width="400" height="330"></embed></object>',
|
data/test/test-bb-ruby.rb
CHANGED
@@ -159,6 +159,16 @@ class TestBBRuby < Test::Unit::TestCase
|
|
159
159
|
assert_equal "<strong>[i]foobar[/i]</strong>", "[b][i]foobar[/i][/b]".bbcode_to_html({}, true, :enable, :bold)
|
160
160
|
assert_equal "<strong><em>foobar</em></strong>", "[b][i]foobar[/i][/b]".bbcode_to_html({}, true, :enable, :bold, :italics)
|
161
161
|
end
|
162
|
+
|
163
|
+
def test_to_html_bang_method
|
164
|
+
foo = "[b]foobar[/b]"
|
165
|
+
assert_equal "<strong>foobar</strong>", foo.bbcode_to_html!
|
166
|
+
assert_equal "<strong>foobar</strong>", foo
|
167
|
+
end
|
168
|
+
|
169
|
+
def test_self_tag_list
|
170
|
+
assert_equal 30, BBRuby.tag_list.size
|
171
|
+
end
|
162
172
|
|
163
173
|
def test_redefinition_of_tag_html
|
164
174
|
mydef = {
|
@@ -192,4 +202,9 @@ class TestBBRuby < Test::Unit::TestCase
|
|
192
202
|
assert_equal '<div class="post_image"><img src="http://zoople/hochzeit.png" alt="" /></div>', '[img]http://zoople/hochzeit.png[/img]'.bbcode_to_html(mydef)
|
193
203
|
end
|
194
204
|
|
205
|
+
def test_multiple_tag_test
|
206
|
+
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
|
207
|
+
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)
|
208
|
+
end
|
209
|
+
|
195
210
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cpjolicoeur-bb-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.1
|
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: 2008-11-
|
12
|
+
date: 2008-11-25 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|