bbcodeizer 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/bbcodeizer/version.rb +1 -1
- data/lib/bbcodeizer.rb +10 -2
- data/lib/bbcodeizer_helper.rb +1 -1
- data/test/bbcodeizer_test.rb +16 -0
- metadata +1 -1
data/lib/bbcodeizer/version.rb
CHANGED
data/lib/bbcodeizer.rb
CHANGED
@@ -65,7 +65,8 @@ module BBCodeizer
|
|
65
65
|
# Parses all bbcode in +text+ and returns a new HTML-formatted string.
|
66
66
|
def bbcodeize(text)
|
67
67
|
text = text.dup
|
68
|
-
|
68
|
+
@deactivated ||= Array.new
|
69
|
+
(TagList - @deactivated).each do |tag|
|
69
70
|
if Tags.has_key?(tag)
|
70
71
|
apply_tag(text, tag)
|
71
72
|
else
|
@@ -80,7 +81,14 @@ module BBCodeizer
|
|
80
81
|
|
81
82
|
# Configuration option to deactivate particular +tags+.
|
82
83
|
def deactivate(*tags)
|
83
|
-
|
84
|
+
@deactivated ||= Array.new
|
85
|
+
@deactivated += tags
|
86
|
+
end
|
87
|
+
|
88
|
+
# Configuration option to reactivate particular +tags+.
|
89
|
+
def activate(*tags)
|
90
|
+
@deactivated ||= Array.new
|
91
|
+
@deactivated -= tags
|
84
92
|
end
|
85
93
|
|
86
94
|
# Configuration option to change the replacement string used for a particular +tag+. The source
|
data/lib/bbcodeizer_helper.rb
CHANGED
data/test/bbcodeizer_test.rb
CHANGED
@@ -105,4 +105,20 @@ class BbcodeizerTest < Test::Unit::TestCase
|
|
105
105
|
"<span style=\"color: red\">Red Text</span>",
|
106
106
|
bbcodeize("[color=red]Red Text[/color]"))
|
107
107
|
end
|
108
|
+
|
109
|
+
def test_deactivation
|
110
|
+
BBCodeizer.deactivate(:bold)
|
111
|
+
assert_equal(
|
112
|
+
"I am [b]really[/b] happy!",
|
113
|
+
bbcodeize("I am [b]really[/b] happy!"))
|
114
|
+
BBCodeizer.activate(:bold) # for future tests
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_activation
|
118
|
+
BBCodeizer.deactivate(:bold)
|
119
|
+
BBCodeizer.activate(:bold)
|
120
|
+
assert_equal(
|
121
|
+
"I am <strong>really</strong> happy!",
|
122
|
+
bbcodeize("I am [b]really[/b] happy!"))
|
123
|
+
end
|
108
124
|
end
|