bbcoder 0.1.6 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/bbcoder/base.rb +1 -1
- data/lib/bbcoder/buffer_tags.rb +8 -8
- data/lib/bbcoder/version.rb +1 -1
- data/spec/bbcoder_spec.rb +20 -0
- metadata +6 -6
data/lib/bbcoder/base.rb
CHANGED
data/lib/bbcoder/buffer_tags.rb
CHANGED
@@ -8,29 +8,29 @@ class BBCoder
|
|
8
8
|
@_meta = {}
|
9
9
|
end
|
10
10
|
|
11
|
-
def push(
|
12
|
-
tag, meta = if
|
13
|
-
splits =
|
11
|
+
def push(original_tag)
|
12
|
+
tag, meta = if original_tag.include?("=")
|
13
|
+
splits = original_tag.split("=")
|
14
14
|
[splits.shift.downcase.to_sym, splits.join('=')]
|
15
15
|
else
|
16
|
-
[
|
16
|
+
[original_tag.downcase.to_sym, nil]
|
17
17
|
end
|
18
18
|
|
19
19
|
if criteria_met?(tag)
|
20
20
|
_internal.push(tag)
|
21
21
|
_meta[size] = meta
|
22
22
|
else
|
23
|
-
buffer.push(BBCoder::Tag.reform(
|
23
|
+
buffer.push(BBCoder::Tag.reform(original_tag, meta))
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
# logic when popping specific tag
|
28
|
-
def pop(
|
29
|
-
tag =
|
28
|
+
def pop(original_tag)
|
29
|
+
tag = original_tag.downcase.to_sym
|
30
30
|
|
31
31
|
# no more tags left to pop || this tag isn't in the list
|
32
32
|
if empty? || !include?(tag)
|
33
|
-
buffer.push("[/#{
|
33
|
+
buffer.push("[/#{original_tag}]")
|
34
34
|
elsif last == tag
|
35
35
|
buffer.push(BBCoder::Tag.to_html(_internal.pop, _meta.delete(size+1), buffer.pop(+1)))
|
36
36
|
elsif include?(tag)
|
data/lib/bbcoder/version.rb
CHANGED
data/spec/bbcoder_spec.rb
CHANGED
@@ -29,6 +29,26 @@ EOS
|
|
29
29
|
string.bbcode_to_html.should == result
|
30
30
|
end
|
31
31
|
|
32
|
+
it "should parse content with ] in it" do
|
33
|
+
'[p]Hi :][/p]'.bbcode_to_html.should == '<p>Hi :]</p>'
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should parse content with [ in it" do
|
37
|
+
'[p]Bye :[[/p]'.bbcode_to_html.should == '<p>Bye :[</p>'
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should act cool and parse content with lots of [ and ] in it" do
|
41
|
+
'[b]Bye :[ Bye :[ Miss :] [i]American :] wait...[/i] :[]..:()[/b]'.bbcode_to_html.should == '<strong>Bye :[ Bye :[ Miss :] <em>American :] wait...</em> :[]..:()</strong>'
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should not downcase content that looks like a tag when being reformed" do
|
45
|
+
'[ Miss ]'.bbcode_to_html.should == '[ Miss ]'
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should not downcase content that looks like a tag when being reformed" do
|
49
|
+
'[/ Mister ]'.bbcode_to_html.should == '[/ Mister ]'
|
50
|
+
end
|
51
|
+
|
32
52
|
it "should return tags as text on blank content" do
|
33
53
|
'[img][/img]'.bbcode_to_html.should == '[img][/img]'
|
34
54
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bbcoder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-02-07 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &17173760 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *17173760
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rr
|
27
|
-
requirement: &
|
27
|
+
requirement: &17173340 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *17173340
|
36
36
|
description: A gem for parsing bbcode that doesn't rely on regular expressions
|
37
37
|
email:
|
38
38
|
- machinist@asceth.com
|