bb-ruby 1.0.2 → 1.0.3

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.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YzBkYjZmZTMzM2RmOWIwODBlNjlhZjdkOWRhMzc3M2I1MTM0ZDIwZg==
5
+ data.tar.gz: !binary |-
6
+ MThhM2Y4ODRhMjZjNTNiMzFjZmI5YzgyOTllZGY3YzEwOTQ1NzA1OQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ Njc2ZDcxNzVlY2I5NTZlOTk0MzM2ZWJlM2IyM2E2ZDlhNjA2MDUwNmRkNjk1
10
+ M2NiMjg1NDg5ODEwNzc3OGQwOTkwZjNkMzViZjJiOTIwNDQ2NmRjYzE3OTQ3
11
+ YjBhNTZjMjcxMWExNWY1YWFhNTY3YjE1YzUzMjMzZTkzOTIxNGE=
12
+ data.tar.gz: !binary |-
13
+ NTE3NWJlMmQyYzM1NzQ3Y2YxMGEwMTVhOTNjOWU4OTUzOTVmOTAzODVmZGRk
14
+ Mjk3YzkyOTlmZTg5MjRjOTVkNzBkODYyMWUzMTk5MTgyOTYxMGZlNzM1Yzhi
15
+ YTE0NmQ2MjI1Y2MyZmM5MmFjNDRkN2ZiYzg2YjI3NmUxMGQ3Mzc=
data/.gitignore CHANGED
@@ -8,3 +8,4 @@ config
8
8
  script
9
9
  .DS_Store
10
10
  *.gem
11
+ vendor/
@@ -1,3 +1,7 @@
1
+ == 1.0.3 2013-10-18
2
+
3
+ * Fix but with auto-detection of links without protocol
4
+
1
5
  == 1.0.2 2013-10-08
2
6
 
3
7
  * Add MIT license information
data/Gemfile.lock CHANGED
@@ -1,12 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bb-ruby (1.0)
4
+ bb-ruby (1.0.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- rake (10.0.3)
9
+ rake (10.1.0)
10
10
 
11
11
  PLATFORMS
12
12
  ruby
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2008 Craig P Jolicoeur
3
+ Copyright (c) 2008 Craig P Jolicoeur, Fernando Blat
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of
6
6
  this software and associated documentation files (the "Software"), to deal in
data/README.md ADDED
@@ -0,0 +1,108 @@
1
+ # BBRuby
2
+
3
+ * [http://rubygems.org/gems/bb-ruby](http://rubygems.org/gems/bb-ruby) [![Build Status](https://travis-ci.org/cpjolicoeur/bb-ruby.png?branch=master)](https://travis-ci.org/cpjolicoeur/bb-ruby)
4
+
5
+ ## Description:
6
+
7
+ BBRuby is a [BBCode](http://www.bbcode.org) implementation for Ruby. It will convert strings with BBCode markup to their HTML equivalent.
8
+
9
+ ## Installation:
10
+
11
+ gem install bb-ruby
12
+
13
+
14
+ ## Usage:
15
+
16
+ require 'bb-ruby'
17
+
18
+ BBRuby has been included directly into the String class for use on any string object:
19
+
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
+ BBRuby will auto-escape HTML tags. To prevent this just pass false as the second param:
25
+
26
+ output = text.bbcode_to_html({}, false)
27
+
28
+ Only allow certain tags:
29
+
30
+ output = text.bbcode_to_html({}, true, :enable, :image, :bold, :quote)
31
+
32
+ Disable certain tags:
33
+
34
+ output = text.bbcode_to_html({}, true, :disable, :image, :bold, :quote)
35
+
36
+ Alternative Direct usage:
37
+
38
+ output = BBRuby.to_html(bbcode_markup)
39
+
40
+ Define your own translation, in order to be more flexible:
41
+
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
+ Define Proc as replacement:
55
+
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
+
70
+ output = text.bbcode_to_html_with_formatting
71
+ output = text.bbcode_to_html_with_formatting!
72
+
73
+
74
+ ### TAGS PROCESSED:
75
+
76
+ The following is the list of BBCode tags processed by BBRuby and their associated symbol for enabling/disabling them
77
+
78
+ [b] :bold
79
+ [i] :italics
80
+ [u] :underline
81
+ [s] :strikeout
82
+ [del] :delete
83
+ [ins] :insert
84
+ [code] :code
85
+ [size] :size
86
+ [color] :color
87
+ [ol] :orderedlist
88
+ [ul] :unorderedlist
89
+ [li] :listitem
90
+ [*] :listitem
91
+ [list] :listitem
92
+ [list=1] :listitem
93
+ [list=a] :listitem
94
+ [dl] :definelist
95
+ [dt] :defineterm
96
+ [dd] :definition
97
+ [quote] :quote
98
+ [quote=source] :quote
99
+ [url=link] :link
100
+ [url] :link
101
+ [img size=] :image
102
+ [img=] :image
103
+ [img] :image
104
+ [youtube] :video
105
+ [gvideo] :video
106
+ [vimeo] :video
107
+ [email] :email
108
+ [align] :align
data/lib/bb-ruby.rb CHANGED
@@ -1,5 +1,3 @@
1
- require "bb-ruby/version"
2
-
3
1
  module BBRuby
4
2
  # allowable image formats
5
3
  @@imageformats = 'png|bmp|jpg|gif|jpeg'
@@ -147,11 +145,17 @@ module BBRuby
147
145
  "Maybe try looking on [url]http://google.com[/url]",
148
146
  :link],
149
147
  'Link (Automatic)' => [
150
- /(\A|\s)((https?:\/\/|www\.)[^\s<]+)/,
148
+ /(\A|\s)(https?:\/\/[^\s<]+)/,
151
149
  ' <a href="\2">\2</a>',
152
150
  'Hyperlink (automatic)',
153
151
  'Maybe try looking on http://www.google.com',
154
152
  :link],
153
+ 'Link (Automatic without leading http(s))' => [
154
+ /(\A|\s)(www\.[^\s<]+)/,
155
+ ' <a href="http://\2">\2</a>',
156
+ 'Hyperlink (automatic without leading http(s))',
157
+ 'Maybe try looking on www.google.com',
158
+ :link],
155
159
  'Image (Resized)' => [
156
160
  /\[img(:.+)? size=#{@@quote_matcher}(\d+)x(\d+)\2\](.*?)\[\/img\1?\]/im,
157
161
  '<img src="\5" style="width: \3px; height: \4px;" />',
@@ -1,3 +1,3 @@
1
1
  module BBRuby
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
data/test/bb-ruby_test.rb CHANGED
@@ -168,6 +168,11 @@ class TestBBRuby < Test::Unit::TestCase
168
168
  assert_equal %Q(Try using google <a href="http://google.com">http://google.com</a>), 'Try using google http://google.com'.bbcode_to_html
169
169
  assert_equal %Q(Try using googlehttp://google.com), 'Try using googlehttp://google.com'.bbcode_to_html
170
170
  assert_equal %Q( <a href="http://google.com">http://google.com</a>), 'http://google.com'.bbcode_to_html
171
+ # links without leading http(s)
172
+ assert_equal %Q(previous text <a href="http://www.google.com">www.google.com</a> post text), 'previous text www.google.com post text'.bbcode_to_html
173
+ assert_equal %Q(Try using google <a href="http://www.google.com">www.google.com</a>), 'Try using google www.google.com'.bbcode_to_html
174
+ assert_equal %Q(Try using googlewww.google.com), 'Try using googlewww.google.com'.bbcode_to_html
175
+ assert_equal %Q( <a href="http://www.google.com">www.google.com</a>), 'www.google.com'.bbcode_to_html
171
176
  end
172
177
 
173
178
  def test_html_escaping
@@ -212,7 +217,7 @@ class TestBBRuby < Test::Unit::TestCase
212
217
  end
213
218
 
214
219
  def test_self_tag_list
215
- assert_equal 33, BBRuby.tag_list.size
220
+ assert_equal 34, BBRuby.tag_list.size
216
221
  end
217
222
 
218
223
  def test_redefinition_of_tag_html
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bb-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
5
- prerelease:
4
+ version: 1.0.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Craig P. Jolicoeur
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-10-08 00:00:00.000000000 Z
11
+ date: 2013-10-18 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: BBCode for Ruby
15
14
  email:
@@ -20,11 +19,11 @@ extra_rdoc_files: []
20
19
  files:
21
20
  - .gitignore
22
21
  - .travis.yml
22
+ - CHANGELOG
23
23
  - Gemfile
24
24
  - Gemfile.lock
25
- - History.txt
26
- - License.txt
27
- - README.rdoc
25
+ - LICENSE
26
+ - README.md
28
27
  - Rakefile
29
28
  - bb-ruby.gemspec
30
29
  - lib/bb-ruby.rb
@@ -34,27 +33,26 @@ files:
34
33
  homepage: http://cpjolicoeur.github.io/bb-ruby/
35
34
  licenses:
36
35
  - MIT
36
+ metadata: {}
37
37
  post_install_message:
38
38
  rdoc_options: []
39
39
  require_paths:
40
40
  - lib
41
41
  required_ruby_version: !ruby/object:Gem::Requirement
42
- none: false
43
42
  requirements:
44
43
  - - ! '>='
45
44
  - !ruby/object:Gem::Version
46
45
  version: '0'
47
46
  required_rubygems_version: !ruby/object:Gem::Requirement
48
- none: false
49
47
  requirements:
50
48
  - - ! '>='
51
49
  - !ruby/object:Gem::Version
52
50
  version: '0'
53
51
  requirements: []
54
52
  rubyforge_project:
55
- rubygems_version: 1.8.23
53
+ rubygems_version: 2.1.9
56
54
  signing_key:
57
- specification_version: 3
55
+ specification_version: 4
58
56
  summary: BBRuby is a BBCode implementation for Ruby. It will convert strings with
59
57
  BBCode markup to their HTML equivalent
60
58
  test_files:
data/README.rdoc DELETED
@@ -1,134 +0,0 @@
1
- = BBRuby
2
-
3
- * http://bb-ruby.rubyforge.org
4
-
5
- == DESCRIPTION:
6
-
7
- BBRuby is a BBCode (http://www.bbcode.org) implementation for Ruby. It will convert strings with BBCode markup to their HTML equivalent.
8
-
9
- == INSTALL:
10
-
11
- To install as a gem:
12
-
13
- sudo gem install bb-ruby
14
-
15
- To install as a plugin:
16
-
17
- ./script/plugin install git://github.com/cpjolicoeur/bb-ruby.git
18
-
19
- == USAGE:
20
-
21
- require 'bb-ruby' # (only needed if installed as a gem)
22
-
23
- BBRuby has been included directly into the String class for use on any string object:
24
-
25
- text = "[b]Here is some bold text[/b] followed by some [u]underlined text[/u]"
26
- output = text.bbcode_to_html
27
- text.bbcode_to_html!
28
-
29
- BBRuby will auto-escape HTML tags. To prevent this just pass false as the second param:
30
-
31
- output = text.bbcode_to_html({}, false)
32
-
33
- Only allow certain tags:
34
-
35
- output = text.bbcode_to_html({}, true, :enable, :image, :bold, :quote)
36
-
37
- Disable certain tags:
38
-
39
- output = text.bbcode_to_html({}, true, :disable, :image, :bold, :quote)
40
-
41
- Alternative Direct usage:
42
-
43
- output = BBRuby.to_html(bbcode_markup)
44
-
45
- Define your own translation, in order to be more flexible:
46
-
47
- my_blockquote = {
48
- 'Quote' => [
49
- /\[quote(:.*)?=(.*?)\](.*?)\[\/quote\1?\]/mi,
50
- '<div class="quote"><p><cite>\2</cite></p><blockquote>\3</blockquote></div>',
51
- 'Quote with citation',
52
- '[quote=mike]please quote me[/quote]',
53
- :quote
54
- ],
55
- }
56
-
57
- text.bbcode_to_html(my_blockquote)
58
-
59
- Define Proc as replacement:
60
-
61
- module BBRuby
62
- @@tags = @@tags.merge({
63
- 'File' => [
64
- /\[file(:.*)?=(.*?)\](.*?)\[\/file\1?\]/mi,
65
- lambda{ |e| "<div class="file"><p><cite>#{e[3]}</cite></p><blockquote>#{file_read_method(e[2])}</blockquote></div>"},
66
- 'File content with citation',
67
- '[file=script.rb]Script Caption[/file]',
68
- :file
69
- ],
70
- })
71
- end
72
-
73
- You can also use the simple_format method of ActionPack by using the *_with_formatting methods:
74
-
75
- output = text.bbcode_to_html_with_formatting
76
- output = text.bbcode_to_html_with_formatting!
77
-
78
-
79
- == TAGS PROCESSED:
80
-
81
- The following is the list of BBCode tags processed by BBRuby and their associated symbol for enabling/disabling them
82
-
83
- * [b] :bold
84
- * [i] :italics
85
- * [u] :underline
86
- * [s] :strikeout
87
- * [del] :delete
88
- * [ins] :insert
89
- * [code] :code
90
- * [size] :size
91
- * [color] :color
92
- * [ol] :orderedlist
93
- * [ul] :unorderedlist
94
- * [li] :listitem
95
- * [*] :listitem
96
- * [list] :listitem
97
- * [list=1] :listitem
98
- * [list=a] :listitem
99
- * [dl] :definelist
100
- * [dt] :defineterm
101
- * [dd] :definition
102
- * [quote] :quote
103
- * [quote=source] :quote
104
- * [url=link] :link
105
- * [url] :link
106
- * [img size=] :image
107
- * [img=] :image
108
- * [img] :image
109
- * [youtube] :video
110
- * [gvideo] :video
111
- * [vimeo] :video
112
- * [email] :email
113
-
114
- == LICENSE:
115
-
116
- Copyright (c) 2008 Craig P Jolicoeur, Fernando Blat
117
-
118
- Permission is hereby granted, free of charge, to any person obtaining a copy
119
- of this software and associated documentation files (the "Software"), to deal
120
- in the Software without restriction, including without limitation the rights
121
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
122
- copies of the Software, and to permit persons to whom the Software is
123
- furnished to do so, subject to the following conditions:
124
-
125
- The above copyright notice and this permission notice shall be included in
126
- all copies or substantial portions of the Software.
127
-
128
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
129
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
130
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
131
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
132
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
133
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
134
- THE SOFTWARE.