Class: Leandocument::Markdown
- Defined in:
- lib/leandocument/render/markdown.rb
Instance Attribute Summary
Attributes inherited from Render
#content, #indent, #p_toc, #path
Instance Method Summary collapse
-
#exec_trans ⇒ Object
Convert to something from content.
- #indented_content ⇒ Object
- #to_html ⇒ Object
Methods inherited from Render
#analyse_content, #content_ary, #initialize, #title
Constructor Details
This class inherits a constructor from Leandocument::Render
Instance Method Details
#exec_trans ⇒ Object
Convert to something from content. Currently, Change indent level. TODO support plugin and expand format.
Return
Text content.
12 13 14 15 16 |
# File 'lib/leandocument/render/markdown.rb', line 12 def exec_trans content = indented_content # .. image:: images/ball1.gif content = content.gsub(/^!\[(.*)\]\((.*)\)/, '![\\1]('+self.path+'\\2)') # For image end |
#indented_content ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/leandocument/render/markdown.rb', line 18 def indented_content content = analyse_content self.indent.times do |i| content = content.to_s.gsub(/^#/, "##") end unless self.indent == 1 content = "#{"#"*self.indent}#{title}\n#{content}" end content end |
#to_html ⇒ Object
3 4 5 |
# File 'lib/leandocument/render/markdown.rb', line 3 def to_html RDiscount.new(exec_trans).to_html end |