bb-ruby 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/CHANGELOG +4 -0
- data/Gemfile.lock +1 -1
- data/lib/bb-ruby.rb +14 -23
- data/lib/bb-ruby/version.rb +1 -1
- data/test/bb-ruby_test.rb +7 -6
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
MThhM2Y4ODRhMjZjNTNiMzFjZmI5YzgyOTllZGY3YzEwOTQ1NzA1OQ==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 890a3b596d2881b1e153b7517156830f7825d927
|
4
|
+
data.tar.gz: 22584247d6b69600a05bea1f975cef76dd4e93f2
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
M2NiMjg1NDg5ODEwNzc3OGQwOTkwZjNkMzViZjJiOTIwNDQ2NmRjYzE3OTQ3
|
11
|
-
YjBhNTZjMjcxMWExNWY1YWFhNTY3YjE1YzUzMjMzZTkzOTIxNGE=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NTE3NWJlMmQyYzM1NzQ3Y2YxMGEwMTVhOTNjOWU4OTUzOTVmOTAzODVmZGRk
|
14
|
-
Mjk3YzkyOTlmZTg5MjRjOTVkNzBkODYyMWUzMTk5MTgyOTYxMGZlNzM1Yzhi
|
15
|
-
YTE0NmQ2MjI1Y2MyZmM5MmFjNDRkN2ZiYzg2YjI3NmUxMGQ3Mzc=
|
6
|
+
metadata.gz: 05ced520bf0cf1c2c980541c4a561d3f014ad53f143c92397c4e53d1dd19ab6d84d6f994159cdfb44c87448465ab36283efb94e3486fb36a8b1332c3568af310
|
7
|
+
data.tar.gz: e4e10c20c73427e80561aac51a4e8bc491e209198d3bbc2b23353affa8c4dcd59aec07936c58d5c7878e8c32a905472eb26f52de9a705110839cd0a0b54539a5
|
data/CHANGELOG
CHANGED
data/Gemfile.lock
CHANGED
data/lib/bb-ruby.rb
CHANGED
@@ -257,13 +257,6 @@ module BBRuby
|
|
257
257
|
# parse spacing
|
258
258
|
text.gsub!( /\r\n?/, "\n" )
|
259
259
|
|
260
|
-
# Special [quote] tag handling
|
261
|
-
if :enable == method && tags.include?(:quote)
|
262
|
-
text.gsub!(/\[quote\]/, '<fieldset><legend>Quote:</legend><blockquote>')
|
263
|
-
text.gsub!(/\[quote(:.*)?="?(.*?)"?\]/, '<fieldset><legend>Quote: \2</legend><blockquote>')
|
264
|
-
text.gsub!(/\[\/quote\]/, '</blockquote></fieldset>')
|
265
|
-
end
|
266
|
-
|
267
260
|
# return markup
|
268
261
|
text
|
269
262
|
end
|
@@ -306,32 +299,30 @@ module BBRuby
|
|
306
299
|
case method
|
307
300
|
when :enable
|
308
301
|
tags_definition.each_value do |t|
|
309
|
-
if tags.include?( t[4] )
|
310
|
-
if t[1].class == String
|
311
|
-
text.gsub!( t[0], t[1] ) # just replace if replacement is String
|
312
|
-
else
|
313
|
-
text.gsub!( t[0] ){ t[1].call($~) } # call replacement
|
314
|
-
# It may be Proc or lambda with one argument
|
315
|
-
# Argument is MatchData. See 'Bold' tag name for example.
|
316
|
-
end
|
317
|
-
end
|
302
|
+
gsub!(text, t[0], t[1]) if tags.include?( t[4] )
|
318
303
|
end
|
319
304
|
when :disable
|
320
305
|
# this works nicely because the default is disable and the default set of tags is [] (so none disabled) :)
|
321
306
|
tags_definition.each_value do |t|
|
322
|
-
unless tags.include?( t[4] )
|
323
|
-
if t[1].class == String
|
324
|
-
text.gsub!( t[0], t[1] )
|
325
|
-
else
|
326
|
-
text.gsub!( t[0] ){ t[1].call($~) }
|
327
|
-
end
|
328
|
-
end
|
307
|
+
gsub!(text, t[0], t[1]) unless tags.include?( t[4] )
|
329
308
|
end
|
330
309
|
end
|
331
310
|
|
332
311
|
text
|
333
312
|
end
|
334
313
|
|
314
|
+
def gsub!(text, pattern, replacement)
|
315
|
+
if replacement.class == String
|
316
|
+
# just replace if replacement is String
|
317
|
+
while text.gsub!( pattern, replacement ); end
|
318
|
+
else
|
319
|
+
# call replacement
|
320
|
+
# It may be Proc or lambda with one argument
|
321
|
+
# Argument is MatchData. See 'Bold' tag name for example.
|
322
|
+
while text.gsub!( pattern ){ replacement.call($~) }; end
|
323
|
+
end
|
324
|
+
end
|
325
|
+
|
335
326
|
# extracted from Rails ActionPack
|
336
327
|
def simple_format( text )
|
337
328
|
start_tag = '<p>'
|
data/lib/bb-ruby/version.rb
CHANGED
data/test/bb-ruby_test.rb
CHANGED
@@ -112,12 +112,6 @@ class TestBBRuby < Test::Unit::TestCase
|
|
112
112
|
assert_equal '<fieldset><legend>Who</legend><blockquote>said that</blockquote></fieldset>', '[quote=Who]said that[/quote]'.bbcode_to_html.bbcode_to_html({}, false, :disable)
|
113
113
|
end
|
114
114
|
|
115
|
-
# FIXME: failing test
|
116
|
-
# def test_double_quote
|
117
|
-
# assert_equal '<fieldset><legend>Kitten</legend><blockquote><fieldset><legend>Quote: "creatiu"</legend><blockquote>f1</blockquote></fieldset>f2</blockquote></fieldset>',
|
118
|
-
# '[quote:26fe26a6a9="Kitten"][quote:26fe26a6a93="creatiu"]f1[/quote:26fe26a6a93]f2[/quote:26fe26a6a9]'.bbcode_to_html.bbcode_to_html({}, false, :disable)
|
119
|
-
# end
|
120
|
-
|
121
115
|
def test_link
|
122
116
|
assert_equal '<a href="http://google.com">Google</a>', '[url=http://google.com]Google[/url]'.bbcode_to_html
|
123
117
|
assert_equal '<a href="http://google.com">http://google.com</a>', '[url]http://google.com[/url]'.bbcode_to_html
|
@@ -323,4 +317,11 @@ class TestBBRuby < Test::Unit::TestCase
|
|
323
317
|
assert_equal '<span class="copy">© 2913-3013 The Company, Ltd.</span>', '[copy/]'.bbcode_to_html(mydef)
|
324
318
|
end
|
325
319
|
|
320
|
+
def test_nested_tags
|
321
|
+
assert_equal '<span style="color: red;">Red Text<span style="color: green;">Green Text</span>Red Again</span>', '[color=red]Red Text[color=green]Green Text[/color]Red Again[/color]'.bbcode_to_html
|
322
|
+
assert_equal '<fieldset><blockquote>first<fieldset><blockquote>second</blockquote></fieldset>first again</blockquote></fieldset>', '[quote]first[quote]second[/quote]first again[/quote]'.bbcode_to_html
|
323
|
+
assert_equal '<fieldset><legend>first author</legend><blockquote>first<fieldset><legend>second author</legend><blockquote>second</blockquote></fieldset>first again</blockquote></fieldset>', '[quote="first author"]first[quote="second author"]second[/quote]first again[/quote]'.bbcode_to_html
|
324
|
+
assert_equal '<fieldset><legend>Kitten</legend><blockquote><fieldset><legend>creatiu</legend><blockquote>f1</blockquote></fieldset>f2</blockquote></fieldset>', '[quote:26fe26a6a9="Kitten"][quote:26fe26a6a93="creatiu"]f1[/quote:26fe26a6a93]f2[/quote:26fe26a6a9]'.bbcode_to_html.bbcode_to_html({}, false, :disable)
|
325
|
+
end
|
326
|
+
|
326
327
|
end
|
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.0.
|
4
|
+
version: 1.0.4
|
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: 2014-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: BBCode for Ruby
|
14
14
|
email:
|
@@ -17,8 +17,8 @@ executables: []
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
-
- .gitignore
|
21
|
-
- .travis.yml
|
20
|
+
- ".gitignore"
|
21
|
+
- ".travis.yml"
|
22
22
|
- CHANGELOG
|
23
23
|
- Gemfile
|
24
24
|
- Gemfile.lock
|
@@ -40,17 +40,17 @@ require_paths:
|
|
40
40
|
- lib
|
41
41
|
required_ruby_version: !ruby/object:Gem::Requirement
|
42
42
|
requirements:
|
43
|
-
- -
|
43
|
+
- - ">="
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
46
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
47
|
requirements:
|
48
|
-
- -
|
48
|
+
- - ">="
|
49
49
|
- !ruby/object:Gem::Version
|
50
50
|
version: '0'
|
51
51
|
requirements: []
|
52
52
|
rubyforge_project:
|
53
|
-
rubygems_version: 2.1
|
53
|
+
rubygems_version: 2.2.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
|