Skip to content

Commit

Permalink
Dont add extra html markup unless asked to by *_with_formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
cpjolicoeur committed Feb 2, 2013
1 parent e928e16 commit 4d7c28d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
6 changes: 5 additions & 1 deletion History.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
== 0.9.9 2013-02-2

* Dont insert any extra html tags if just using .to_html method

== 0.9.8 2012-10-03

* replace deprecated html <u> tag
Expand Down Expand Up @@ -54,4 +58,4 @@

* No major enhancements:
* Small point release for moving gem from Github to RubyForge
* Gem is no longer served from github via cpjolicoeur-bbruby. Gem is now served directly from Rubyforge via bb-ruby
* Gem is no longer served from github via cpjolicoeur-bbruby. Gem is now served directly from Rubyforge via bb-ruby
2 changes: 1 addition & 1 deletion lib/bb-ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def to_html(text, tags_alternative_definition={}, escape_html=true, method=:disa

# parse spacing
text.gsub!( /\r\n?/, "\n" )
text.gsub!( /\n/, "<br />\n" )

text.gsub!(/\[quote\]/, '<fieldset><legend>Quote:</legend><blockquote>')
text.gsub!(/\[quote(:.*)?="?(.*?)"?\]/, '<fieldset><legend>Quote: \2</legend><blockquote>')
text.gsub!(/\[\/quote\]/, '</blockquote></fieldset>')
Expand Down
2 changes: 1 addition & 1 deletion lib/bb-ruby/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module BBRuby
VERSION = "0.9.8"
VERSION = "0.9.9"
end
18 changes: 9 additions & 9 deletions test/bb-ruby_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ def test_strong
assert_equal '<strong>simple</strong>', '[b]simple[/b]'.bbcode_to_html
assert_equal '<strong>simple</strong>', '[b:7a9ca2c5c3]simple[/b:7a9ca2c5c3]'.bbcode_to_html
assert_equal %Q(<strong>simple</strong>), BBRuby.to_html( %Q([b:7a9ca2c5c3]simple[/b:7a9ca2c5c3]) )
assert_equal "<strong>line 1<br />\nline 2</strong>", "[b:7a9ca2c5c3]line 1\nline 2[/b:7a9ca2c5c3]".bbcode_to_html
assert_equal "<strong>1. text 1:</strong> text 2<br />\n<strong>2. text 3</strong>", "[b:post_uid0]1. text 1:[/b:post_uid0] text 2\n[b:post_uid0]2. text 3[/b:post_uid0]".bbcode_to_html
assert_equal "<strong>line 1\nline 2</strong>", "[b:7a9ca2c5c3]line 1\nline 2[/b:7a9ca2c5c3]".bbcode_to_html
assert_equal "<strong>1. text 1:</strong> text 2\n<strong>2. text 3</strong>", "[b:post_uid0]1. text 1:[/b:post_uid0] text 2\n[b:post_uid0]2. text 3[/b:post_uid0]".bbcode_to_html
end

def test_em
assert_equal '<em>simple</em>', '[i]simple[/i]'.bbcode_to_html
assert_equal '<em>simple</em>', '[i:7a9ca2c5c3]simple[/i:7a9ca2c5c3]'.bbcode_to_html
assert_equal "<em>line 1<br />\nline 2</em>", "[i:7a9ca2c5c3]line 1\nline 2[/i:7a9ca2c5c3]".bbcode_to_html
assert_equal "<em>line 1\nline 2</em>", "[i:7a9ca2c5c3]line 1\nline 2[/i:7a9ca2c5c3]".bbcode_to_html
end

def test_u
assert_equal '<span style="text-decoration:underline;">simple</span>', '[u]simple[/u]'.bbcode_to_html
assert_equal '<span style="text-decoration:underline;">simple</span>', '[u:7a9ca2c5c3]simple[/u:7a9ca2c5c3]'.bbcode_to_html
assert_equal '<span style="text-decoration:underline;">line 1<br />\nline 2</span>', "[u:7a9ca2c5c3]line 1\nline 2[/u:7a9ca2c5c3]".bbcode_to_html
assert_equal %Q(<span style="text-decoration:underline;">line 1\nline 2</span>), "[u:7a9ca2c5c3]line 1\nline 2[/u:7a9ca2c5c3]".bbcode_to_html
end

def test_del
Expand All @@ -40,7 +40,7 @@ def test_ins
def test_code
assert_equal '<code>simple</code>', '[code]simple[/code]'.bbcode_to_html
assert_equal '<code>simple</code>', '[code:7a9ca2c5c3]simple[/code:7a9ca2c5c3]'.bbcode_to_html
assert_equal "<code>var bxi = 0;<br />\n//Holds current speed of scrolling menu</code>", "[code:1:91cbdd72b7]var bxi = 0;\n//Holds current speed of scrolling menu[/code:1:91cbdd72b7]".bbcode_to_html
assert_equal "<code>var bxi = 0;\n//Holds current speed of scrolling menu</code>", "[code:1:91cbdd72b7]var bxi = 0;\n//Holds current speed of scrolling menu[/code:1:91cbdd72b7]".bbcode_to_html
end

def test_size
Expand Down Expand Up @@ -113,15 +113,15 @@ def test_quote
end

def test_double_quote
assert_equal '<fieldset><legend>Kitten</legend><blockquote><fieldset><legend>creatiu</legend><blockquote>f1</blockquote></fieldset>f2</blockquote></fieldset>',
assert_equal '<fieldset><legend>Kitten</legend><blockquote><fieldset><legend>Quote: &quot;creatiu&quot;</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)
end

def test_link
assert_equal '<a href="http://google.com">Google</a>', '[url=http://google.com]Google[/url]'.bbcode_to_html
assert_equal '<a href="http://google.com">http://google.com</a>', '[url]http://google.com[/url]'.bbcode_to_html
assert_equal '<a href="http://www.altctrlsupr.com/dmstk/kdd070803/00.html"> ABRIR ALBUM </a>','[URL=http://www.altctrlsupr.com/dmstk/kdd070803/00.html] ABRIR ALBUM [/URL]'.bbcode_to_html
assert_equal %Q(<a href="http://www.altctrlsupr.com/dmstk/kdd070803/00.html"> ABRIR<br />\nALBUM </a>),"[URL=http://www.altctrlsupr.com/dmstk/kdd070803/00.html] ABRIR\nALBUM [/URL]".bbcode_to_html
assert_equal %Q(<a href="http://www.altctrlsupr.com/dmstk/kdd070803/00.html"> ABRIR\nALBUM </a>),"[URL=http://www.altctrlsupr.com/dmstk/kdd070803/00.html] ABRIR\nALBUM [/URL]".bbcode_to_html
assert_equal '<a href="http://www.urimalet.com/cadaverex.mp3">aha</a>', "[URL=http://www.urimalet.com/cadaverex.mp3]aha[/URL]".bbcode_to_html
# allow quoted urls:
assert_equal '<a href="http://www.apple.com">aha</a>', '[URL="http://www.apple.com"]aha[/URL]'.bbcode_to_html
Expand Down Expand Up @@ -195,7 +195,7 @@ def test_to_html_bang_method

def test_to_html_with_no_markup
foo = "first paragraph\n\nsecond paragraph\nwith a linebreak"
assert_equal "first paragraph<br />\n<br />\nsecond paragraph<br />\nwith a linebreak", foo.bbcode_to_html
assert_equal foo, foo.bbcode_to_html
end

def test_to_html_with_formatting
Expand All @@ -204,7 +204,7 @@ def test_to_html_with_formatting
end

def test_self_tag_list
assert_equal 32, BBRuby.tag_list.size
assert_equal 33, BBRuby.tag_list.size
end

def test_redefinition_of_tag_html
Expand Down

0 comments on commit 4d7c28d

Please sign in to comment.