Module: RubyBBCode
- Includes:
- BBCode::Tags
- Defined in:
- lib/ruby-bbcode.rb
Constant Summary collapse
{:words_connector => "], [", :two_words_connector => "] and [", :last_word_connector => "] and ["}
Class Method Summary collapse
- .is_valid?(text, additional_tags = {}) ⇒ Boolean
- .tag_list ⇒ Object
- .to_html(text, escape_html = true, additional_tags = {}, method = :disable, *tags) ⇒ Object
Class Method Details
.is_valid?(text, additional_tags = {}) ⇒ Boolean
36 37 38 |
# File 'lib/ruby-bbcode.rb', line 36 def self.is_valid?(text, = {}) parse(text, @@tags.merge()); end |
.tag_list ⇒ Object
40 41 42 |
# File 'lib/ruby-bbcode.rb', line 40 def self.tag_list @@tags end |
.to_html(text, escape_html = true, additional_tags = {}, method = :disable, *tags) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/ruby-bbcode.rb', line 10 def self.to_html(text, escape_html = true, = {}, method = :disable, *) # We cannot convert to HTML if the BBCode is not valid! text = text.clone = @@tags.merge() if method == :disable then .each { |t| .delete(t) } else = {} .each { |t| [t] = [t] if .key?(t) } = end if escape_html text.gsub!('<', '<') text.gsub!('>', '>') end text.gsub!("\r\n", "\n") text.gsub!("\n", "<br />\n") valid = parse(text, ) raise valid.join(', ') if valid != true bbtree_to_html(@bbtree[:nodes], ) end |