Module: RubyBBCode
- Includes:
- Tags
- Defined in:
- lib/tags/tags.rb,
lib/ruby-bbcode.rb,
lib/ruby-bbcode/bbtree.rb,
lib/ruby-bbcode/tag_info.rb,
lib/ruby-bbcode/tag_node.rb,
lib/ruby-bbcode/debugging.rb,
lib/ruby-bbcode/tag_sifter.rb,
lib/ruby-bbcode/tag_collection.rb
Defined Under Namespace
Modules: DebugBBTree, Tags Classes: BBTree, TagCollection, TagInfo, TagNode, TagSifter
Class Method Summary collapse
- .clear_log_file_at_beginning_of_execution(clear_file) ⇒ Object
- .log(string, clear_file = true) ⇒ Object
-
.to_html(text, escape_html = true, additional_tags = {}, method = :disable, *tags) ⇒ Object
This method converts the given text (with BBCode tags) into a HTML representation The escape_html parameter (default: true) escapes HTML tags that were present in the given text and therefore blocking (mallicious) HTML in the original text The additional_tags parameter is used to add additional BBCode tags that should be accepted The method paramter determines whether the tags parameter needs to be used to blacklist (when set to :disable) or whitelist (when not set to :disable) the list of BBCode tags.
-
.validity_check(text, additional_tags = {}) ⇒ Object
Returns true when valid, else returns array with error(s).
Methods included from Tags
Class Method Details
.clear_log_file_at_beginning_of_execution(clear_file) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/ruby-bbcode/debugging.rb', line 10 def self.clear_log_file_at_beginning_of_execution(clear_file) return if !clear_file if defined?(@@cleared_file).nil? @@cleared_file = true File.open('/tmp/ruby-bbcode.log', 'w+') do |f| puts '' end end end |
.log(string, clear_file = true) ⇒ Object
2 3 4 5 6 7 8 |
# File 'lib/ruby-bbcode/debugging.rb', line 2 def self.log(string, clear_file = true) clear_log_file_at_beginning_of_execution clear_file File.open('/tmp/ruby-bbcode.log', 'a') do |f| f.puts string end end |
.to_html(text, escape_html = true, additional_tags = {}, method = :disable, *tags) ⇒ Object
This method converts the given text (with BBCode tags) into a HTML representation The escape_html parameter (default: true) escapes HTML tags that were present in the given text and therefore blocking (mallicious) HTML in the original text The additional_tags parameter is used to add additional BBCode tags that should be accepted The method paramter determines whether the tags parameter needs to be used to blacklist (when set to :disable) or whitelist (when not set to :disable) the list of BBCode tags
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/ruby-bbcode.rb', line 19 def self.to_html(text, escape_html = true, = {}, method = :disable, *) text = text.clone = (, method, *) @tag_sifter = TagSifter.new(text, , escape_html) @tag_sifter.process_text if @tag_sifter.invalid? raise @tag_sifter.errors.join(', ') # We cannot convert to HTML if the BBCode is not valid! else @tag_sifter.bbtree.to_html() end end |
.validity_check(text, additional_tags = {}) ⇒ Object
Returns true when valid, else returns array with error(s)
37 38 39 40 41 42 43 |
# File 'lib/ruby-bbcode.rb', line 37 def self.validity_check(text, = {}) @tag_sifter = TagSifter.new(text, .merge()) @tag_sifter.process_text return @tag_sifter.errors if @tag_sifter.invalid? true end |