Class: RDocText
- Inherits:
-
String
- Object
- String
- RDocText
- Defined in:
- lib/acts_as_markup/exts/rdoc.rb
Overview
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.
Instance Attribute Summary collapse
-
#html ⇒ Object
readonly
Returns the value of attribute html.
-
#html_formater ⇒ Object
readonly
Returns the value of attribute html_formater.
-
#markup ⇒ Object
readonly
Returns the value of attribute markup.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
-
#initialize(str) ⇒ RDocText
constructor
A new instance of RDocText.
- #to_html ⇒ Object
Constructor Details
#initialize(str) ⇒ RDocText
Returns a new instance of RDocText.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/acts_as_markup/exts/rdoc.rb', line 73 def initialize(str) super(str) @text = str.to_s @markup = SM::SimpleMarkup.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 |
Instance Attribute Details
#html ⇒ Object (readonly)
Returns the value of attribute html.
69 70 71 |
# File 'lib/acts_as_markup/exts/rdoc.rb', line 69 def html @html end |
#html_formater ⇒ Object (readonly)
Returns the value of attribute html_formater.
71 72 73 |
# File 'lib/acts_as_markup/exts/rdoc.rb', line 71 def html_formater @html_formater end |
#markup ⇒ Object (readonly)
Returns the value of attribute markup.
70 71 72 |
# File 'lib/acts_as_markup/exts/rdoc.rb', line 70 def markup @markup end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
68 69 70 |
# File 'lib/acts_as_markup/exts/rdoc.rb', line 68 def text @text end |
Instance Method Details
#to_html ⇒ Object
98 99 100 |
# File 'lib/acts_as_markup/exts/rdoc.rb', line 98 def to_html @html end |