diff --git a/bristlecode.rb b/bristlecode.rb
index 1a5b02a..77d36a2 100644
--- a/bristlecode.rb
+++ b/bristlecode.rb
@@ -9,6 +9,15 @@ module Bristlecode
tree.to_html
end
+ def Bristlecode.clean(text)
+ text.gsub!('&', '&')
+ text.gsub!('<', '<')
+ text.gsub!('>', '>')
+ text.gsub!('"', '"')
+ text.gsub!("'", ''')
+ text.gsub!('/', '/')
+ end
+
class Parser < Parslet::Parser
rule(:space) { match('\s').repeat(1) }
rule(:space?) { space.maybe }
@@ -79,15 +88,7 @@ module Bristlecode
def initialize(text)
self.text = text.to_str.strip
- clean
- end
-
- def clean
- text.gsub!('&', '&')
- text.gsub!('<', '<')
- text.gsub!('>', '>')
- text.gsub!('"', '"')
- text.gsub!("'", ''')
+ Bristlecode.clean(self.text)
end
def to_html
diff --git a/spec/bristlecode/parser_spec.rb b/spec/bristlecode/parser_spec.rb
index e948f62..4c81d9a 100644
--- a/spec/bristlecode/parser_spec.rb
+++ b/spec/bristlecode/parser_spec.rb
@@ -21,8 +21,9 @@ module Bristlecode
expect(to_html('&')).to eq('&')
expect(to_html('>')).to eq('>')
expect(to_html('<')).to eq('<')
- expect(to_html("'")).to eq(''')
+ expect(to_html("'")).to eq(''')
expect(to_html('"')).to eq('"')
+ expect(to_html('/')).to eq('/')
end
it 'handles plain text just fine' do
@@ -66,7 +67,7 @@ module Bristlecode
it 'passes simple url contents opaquely' do
input = '[url]x[b]y[/b]z[/url]'
- output = 'x[b]y[/b]z'
+ output = 'x[b]y[/b]z'
expect(to_html(input)).to eq(output)
end