diff --git a/History.txt b/CHANGELOG similarity index 100% rename from History.txt rename to CHANGELOG diff --git a/License.txt b/LICENSE similarity index 95% rename from License.txt rename to LICENSE index 3633bbf..64af62f 100644 --- a/License.txt +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2008 Craig P Jolicoeur +Copyright (c) 2008 Craig P Jolicoeur, Fernando Blat Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/README.md b/README.md new file mode 100644 index 0000000..3f9274c --- /dev/null +++ b/README.md @@ -0,0 +1,108 @@ +# BBRuby + +* [http://rubygems.org/gems/bb-ruby](http://rubygems.org/gems/bb-ruby) + +## Description: + +BBRuby is a [BBCode](http://www.bbcode.org) implementation for Ruby. It will convert strings with BBCode markup to their HTML equivalent. + +## Installation: + + gem install bb-ruby + + +## Usage: + + require 'bb-ruby' + +BBRuby has been included directly into the String class for use on any string object: + + text = "[b]Here is some bold text[/b] followed by some [u]underlined text[/u]" + output = text.bbcode_to_html + text.bbcode_to_html! + +BBRuby will auto-escape HTML tags. To prevent this just pass false as the second param: + + output = text.bbcode_to_html({}, false) + +Only allow certain tags: + + output = text.bbcode_to_html({}, true, :enable, :image, :bold, :quote) + +Disable certain tags: + + output = text.bbcode_to_html({}, true, :disable, :image, :bold, :quote) + +Alternative Direct usage: + + output = BBRuby.to_html(bbcode_markup) + +Define your own translation, in order to be more flexible: + + my_blockquote = { + 'Quote' => [ + /\[quote(:.*)?=(.*?)\](.*?)\[\/quote\1?\]/mi, + '

\2

\3
', + 'Quote with citation', + '[quote=mike]please quote me[/quote]', + :quote + ], + } + + text.bbcode_to_html(my_blockquote) + +Define Proc as replacement: + + module BBRuby + @@tags = @@tags.merge({ + 'File' => [ + /\[file(:.*)?=(.*?)\](.*?)\[\/file\1?\]/mi, + lambda{ |e| "

#{e[3]}

#{file_read_method(e[2])}
"}, + 'File content with citation', + '[file=script.rb]Script Caption[/file]', + :file + ], + }) + end + +You can also use the simple_format method of ActionPack by using the *_with_formatting methods: + + output = text.bbcode_to_html_with_formatting + output = text.bbcode_to_html_with_formatting! + + +### TAGS PROCESSED: + +The following is the list of BBCode tags processed by BBRuby and their associated symbol for enabling/disabling them + + [b] :bold + [i] :italics + [u] :underline + [s] :strikeout + [del] :delete + [ins] :insert + [code] :code + [size] :size + [color] :color + [ol] :orderedlist + [ul] :unorderedlist + [li] :listitem + [*] :listitem + [list] :listitem + [list=1] :listitem + [list=a] :listitem + [dl] :definelist + [dt] :defineterm + [dd] :definition + [quote] :quote + [quote=source] :quote + [url=link] :link + [url] :link + [img size=] :image + [img=] :image + [img] :image + [youtube] :video + [gvideo] :video + [vimeo] :video + [email] :email + [align] :align \ No newline at end of file diff --git a/README.rdoc b/README.rdoc deleted file mode 100644 index b615c8e..0000000 --- a/README.rdoc +++ /dev/null @@ -1,134 +0,0 @@ -= BBRuby - -* http://bb-ruby.rubyforge.org - -== DESCRIPTION: - -BBRuby is a BBCode (http://www.bbcode.org) implementation for Ruby. It will convert strings with BBCode markup to their HTML equivalent. - -== INSTALL: - -To install as a gem: - - sudo gem install bb-ruby - -To install as a plugin: - - ./script/plugin install git://github.com/cpjolicoeur/bb-ruby.git - -== USAGE: - - require 'bb-ruby' # (only needed if installed as a gem) - -BBRuby has been included directly into the String class for use on any string object: - - text = "[b]Here is some bold text[/b] followed by some [u]underlined text[/u]" - output = text.bbcode_to_html - text.bbcode_to_html! - -BBRuby will auto-escape HTML tags. To prevent this just pass false as the second param: - - output = text.bbcode_to_html({}, false) - -Only allow certain tags: - - output = text.bbcode_to_html({}, true, :enable, :image, :bold, :quote) - -Disable certain tags: - - output = text.bbcode_to_html({}, true, :disable, :image, :bold, :quote) - -Alternative Direct usage: - - output = BBRuby.to_html(bbcode_markup) - -Define your own translation, in order to be more flexible: - - my_blockquote = { - 'Quote' => [ - /\[quote(:.*)?=(.*?)\](.*?)\[\/quote\1?\]/mi, - '

\2

\3
', - 'Quote with citation', - '[quote=mike]please quote me[/quote]', - :quote - ], - } - - text.bbcode_to_html(my_blockquote) - -Define Proc as replacement: - - module BBRuby - @@tags = @@tags.merge({ - 'File' => [ - /\[file(:.*)?=(.*?)\](.*?)\[\/file\1?\]/mi, - lambda{ |e| "

#{e[3]}

#{file_read_method(e[2])}
"}, - 'File content with citation', - '[file=script.rb]Script Caption[/file]', - :file - ], - }) - end - -You can also use the simple_format method of ActionPack by using the *_with_formatting methods: - - output = text.bbcode_to_html_with_formatting - output = text.bbcode_to_html_with_formatting! - - -== TAGS PROCESSED: - -The following is the list of BBCode tags processed by BBRuby and their associated symbol for enabling/disabling them - -* [b] :bold -* [i] :italics -* [u] :underline -* [s] :strikeout -* [del] :delete -* [ins] :insert -* [code] :code -* [size] :size -* [color] :color -* [ol] :orderedlist -* [ul] :unorderedlist -* [li] :listitem -* [*] :listitem -* [list] :listitem -* [list=1] :listitem -* [list=a] :listitem -* [dl] :definelist -* [dt] :defineterm -* [dd] :definition -* [quote] :quote -* [quote=source] :quote -* [url=link] :link -* [url] :link -* [img size=] :image -* [img=] :image -* [img] :image -* [youtube] :video -* [gvideo] :video -* [vimeo] :video -* [email] :email - -== LICENSE: - -Copyright (c) 2008 Craig P Jolicoeur, Fernando Blat - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE.