Module: BBRuby
- Defined in:
- lib/bb-ruby/bb-ruby.rb
Overview
overwrite process_tags method, because original one doesn’t work with nested tags(like citation)‘ also mark returned string as html_safe
Class Method Summary collapse
- .process_tags(text, tags_alternative_definition = {}, escape_html = true, method = :disable, *tags) ⇒ Object
- .to_html_with_formatting_with_html_safe(text, tags_alternative_definition = {}, escape_html = true, method = :disable, *tags) ⇒ Object
- .to_html_with_html_safe(text, tags_alternative_definition = {}, escape_html = true, method = :disable, *tags) ⇒ Object
Class Method Details
.process_tags(text, tags_alternative_definition = {}, escape_html = true, method = :disable, *tags) ⇒ Object
6 7 8 9 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 35 36 37 38 39 40 |
# File 'lib/bb-ruby/bb-ruby.rb', line 6 def (text, ={}, escape_html=true, method=:disable, *) text = text.dup # escape "<, >, &" to remove any html if escape_html text.gsub!('&', '&') text.gsub!('<', '<') text.gsub!('>', '>') end = @@tags.merge() # parse bbcode tags case method when :enable .each_value do |t| if .include?(t[4]) while text.gsub!(t[0], t[1]) do #nothing end end end when :disable # this works nicely because the default is disable and the default set of tags is [] (so none disabled) :) .each_value do |t| unless .include?(t[4]) while text.gsub!(t[0], t[1]) do #nothing end end end end text end |
.to_html_with_formatting_with_html_safe(text, tags_alternative_definition = {}, escape_html = true, method = :disable, *tags) ⇒ Object
49 50 51 52 |
# File 'lib/bb-ruby/bb-ruby.rb', line 49 def to_html_with_formatting_with_html_safe(text, ={}, escape_html=true, method=:disable, *) text = to_html_with_formatting_without_html_safe(text, , escape_html, method, *) text.respond_to?(:html_safe) ? text.html_safe : text end |
.to_html_with_html_safe(text, tags_alternative_definition = {}, escape_html = true, method = :disable, *tags) ⇒ Object
42 43 44 45 |
# File 'lib/bb-ruby/bb-ruby.rb', line 42 def to_html_with_html_safe(text, ={}, escape_html=true, method=:disable, *) text = to_html_without_html_safe(text, , escape_html, method, *) text.respond_to?(:html_safe) ? text.html_safe : text end |