bb-ruby 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/CHANGELOG +4 -0
- data/Gemfile.lock +1 -1
- data/README.md +48 -48
- data/lib/bb-ruby.rb +3 -3
- data/lib/bb-ruby/version.rb +1 -1
- data/test/bb-ruby_test.rb +4 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70b197a69b0f2ef22f95e3c56e14803d2794a1c6
|
4
|
+
data.tar.gz: 01d37bf9261b35ebed4ce3df663554faa82bd1bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf742cda44a7789f8f2d467ff4549b555312c0b59c546fe82e80eb4d8bc3e63b22d2b01899a3fe5138a11d00312467e0ac8632d0d44bd959bd5cf109b7addbdd
|
7
|
+
data.tar.gz: 0ba32520f906667ade9e77b9f73d59c3d3b94b8019994f153ec8b428193f73d96aebed8c05d233d99c6018b99f64e6ad462220336fb568c04033c056071b070b
|
data/.travis.yml
CHANGED
data/CHANGELOG
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -16,60 +16,60 @@ BBRuby is a [BBCode](http://www.bbcode.org) implementation for Ruby. It will con
|
|
16
16
|
require 'bb-ruby'
|
17
17
|
|
18
18
|
BBRuby has been included directly into the String class for use on any string object:
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
```rb
|
20
|
+
text = "[b]Here is some bold text[/b] followed by some [u]underlined text[/u]"
|
21
|
+
output = text.bbcode_to_html
|
22
|
+
text.bbcode_to_html!
|
23
|
+
```
|
24
24
|
BBRuby will auto-escape HTML tags. To prevent this just pass false as the second param:
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
```rb
|
26
|
+
output = text.bbcode_to_html({}, false)
|
27
|
+
```
|
28
28
|
Only allow certain tags:
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
```rb
|
30
|
+
output = text.bbcode_to_html({}, true, :enable, :image, :bold, :quote)
|
31
|
+
```
|
32
32
|
Disable certain tags:
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
```rb
|
34
|
+
output = text.bbcode_to_html({}, true, :disable, :image, :bold, :quote)
|
35
|
+
```
|
36
36
|
Alternative Direct usage:
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
```rb
|
38
|
+
output = BBRuby.to_html(bbcode_markup)
|
39
|
+
```
|
40
40
|
Define your own translation, in order to be more flexible:
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
41
|
+
```rb
|
42
|
+
my_blockquote = {
|
43
|
+
'Quote' => [
|
44
|
+
/\[quote(:.*)?=(.*?)\](.*?)\[\/quote\1?\]/mi,
|
45
|
+
'<div class="quote"><p><cite>\2</cite></p><blockquote>\3</blockquote></div>',
|
46
|
+
'Quote with citation',
|
47
|
+
'[quote=mike]please quote me[/quote]',
|
48
|
+
:quote
|
49
|
+
],
|
50
|
+
}
|
51
|
+
|
52
|
+
text.bbcode_to_html(my_blockquote)
|
53
|
+
```
|
54
54
|
Define Proc as replacement:
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
You can also use the simple_format method of ActionPack by using the *_with_formatting methods:
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
55
|
+
```rb
|
56
|
+
module BBRuby
|
57
|
+
@@tags = @@tags.merge({
|
58
|
+
'File' => [
|
59
|
+
/\[file(:.*)?=(.*?)\](.*?)\[\/file\1?\]/mi,
|
60
|
+
lambda{ |e| "<div class="file"><p><cite>#{e[3]}</cite></p><blockquote>#{file_read_method(e[2])}</blockquote></div>"},
|
61
|
+
'File content with citation',
|
62
|
+
'[file=script.rb]Script Caption[/file]',
|
63
|
+
:file
|
64
|
+
],
|
65
|
+
})
|
66
|
+
end
|
67
|
+
```
|
68
|
+
You can also use the `simple_format` method of ActionPack by using the *_with_formatting methods:
|
69
|
+
```rb
|
70
|
+
output = text.bbcode_to_html_with_formatting
|
71
|
+
output = text.bbcode_to_html_with_formatting!
|
72
|
+
```
|
73
73
|
|
74
74
|
### TAGS PROCESSED:
|
75
75
|
|
data/lib/bb-ruby.rb
CHANGED
@@ -183,20 +183,20 @@ module BBRuby
|
|
183
183
|
'YouTube' => [
|
184
184
|
/\[youtube\](.*?)\?v=([\w\d\-]+).*?\[\/youtube\]/im,
|
185
185
|
# '<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>',
|
186
|
-
'<
|
186
|
+
'<iframe id="ytplayer" type="text/html" width="640" height="390" src="http://www.youtube.com/embed/\2" frameborder="0"/>',
|
187
187
|
'Display a video from YouTube.com',
|
188
188
|
'[youtube]http://youtube.com/watch?v=E4Fbk52Mk1w[/youtube]',
|
189
189
|
:video],
|
190
190
|
'YouTube (Alternative)' => [
|
191
191
|
/\[youtube\](.*?)\/v\/([\w\d\-]+)\[\/youtube\]/im,
|
192
192
|
# '<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>',
|
193
|
-
'<
|
193
|
+
'<iframe id="ytplayer" type="text/html" width="640" height="390" src="http://www.youtube.com/embed/\2" frameborder="0"/>',
|
194
194
|
'Display a video from YouTube.com (alternative format)',
|
195
195
|
'[youtube]http://youtube.com/watch/v/E4Fbk52Mk1w[/youtube]',
|
196
196
|
:video],
|
197
197
|
'Vimeo' => [
|
198
198
|
/\[vimeo\](.*?)\/(\d+)\[\/vimeo\]/im,
|
199
|
-
'<
|
199
|
+
'<iframe src="//player.vimeo.com/video/\2" width="640" height="390" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>',
|
200
200
|
'Display a video from Vimeo',
|
201
201
|
'[vimeo]http://www.vimeo.com/3485239[/vimeo]',
|
202
202
|
:video],
|
data/lib/bb-ruby/version.rb
CHANGED
data/test/bb-ruby_test.rb
CHANGED
@@ -142,13 +142,13 @@ class TestBBRuby < Test::Unit::TestCase
|
|
142
142
|
|
143
143
|
def test_youtube
|
144
144
|
# Uncomment below if using 4:3 format youtube video embed
|
145
|
-
# assert_equal '<
|
146
|
-
assert_equal '<
|
147
|
-
assert_equal '<
|
145
|
+
# assert_equal assert_equal '<iframe id="ytplayer" type="text/html" width="320" height="265" src="http://www.youtube.com/embed/E4Fbk52Mk1w" frameborder="0"/>', '[youtube]http://youtube.com/watch?v=E4Fbk52Mk1w[/youtube]'.bbcode_to_html
|
146
|
+
assert_equal '<iframe id="ytplayer" type="text/html" width="640" height="390" src="http://www.youtube.com/embed/E4Fbk52Mk1w" frameborder="0"/>', '[youtube]http://youtube.com/watch?v=E4Fbk52Mk1w[/youtube]'.bbcode_to_html
|
147
|
+
assert_equal '<iframe id="ytplayer" type="text/html" width="640" height="390" src="http://www.youtube.com/embed/E4Fbk52Mk1w" frameborder="0"/><iframe id="ytplayer" type="text/html" width="640" height="390" src="http://www.youtube.com/embed/abc123" frameborder="0"/>', '[youtube]http://youtube.com/watch?v=E4Fbk52Mk1w[/youtube][youtube]http://youtube.com/watch?v=abc123[/youtube]'.bbcode_to_html
|
148
148
|
end
|
149
149
|
|
150
150
|
def test_vimeo
|
151
|
-
assert_equal '<
|
151
|
+
assert_equal '<iframe src="//player.vimeo.com/video/3485239" width="640" height="390" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>', '[vimeo]http://www.vimeo.com/3485239[/vimeo]'.bbcode_to_html
|
152
152
|
end
|
153
153
|
|
154
154
|
def test_google_video
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bb-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Craig P. Jolicoeur
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: BBCode for Ruby
|
14
14
|
email:
|
@@ -50,7 +50,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
50
50
|
version: '0'
|
51
51
|
requirements: []
|
52
52
|
rubyforge_project:
|
53
|
-
rubygems_version: 2.4.1
|
53
|
+
rubygems_version: 2.4.5.1
|
54
54
|
signing_key:
|
55
55
|
specification_version: 4
|
56
56
|
summary: BBRuby is a BBCode implementation for Ruby. It will convert strings with
|