This allows a us to create a wrapper object similar to those provided by the Markdown and Textile libraries. It stores the original and formated HTML text in instance variables. It also stores the SimpleMarkup parser objects in instance variables.
# File lib/acts_as_markup/exts/rdoc.rb, line 71 def initialize(str) super(str) @text = str.to_s @markup = RDoc::Markup.new # external hyperlinks @markup.add_special(/((link:|https?:|mailto:|ftp:|www\.)\S+\w)/, :HYPERLINK) # and links of the form <text>[<url>] @markup.add_special(/(((\{.*?\})|\b\S+?)\[\S+?\.\S+?\])/, :TIDYLINK) # Convert leading comment markers to spaces, but only # if all non-blank lines have them if str =~ /^(?>\s*)[^\#]/ content = str else content = str.gsub(/^\s*(#+)/) { $1.tr('#',' ') } end @html_formatter = RDocWithHyperlinkToHtml.new @html = @markup.convert(@text, @html_formatter) end
# File lib/acts_as_markup/exts/rdoc.rb, line 96 def to_html @html end