Class: Leandocument::ReStructuredText
- Defined in:
- lib/leandocument/render/re_structured_text.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.
16 17 18 19 |
# File 'lib/leandocument/render/re_structured_text.rb', line 16 def exec_trans content = indented_content content = content.gsub(/^\.\. image:: (.*)$/, '.. image:: '+self.path+'\\1') # For image end |
#indented_content ⇒ Object
21 22 23 24 25 26 |
# File 'lib/leandocument/render/re_structured_text.rb', line 21 def indented_content content = analyse_content unless self.indent == 1 content = "#{"="*30}\n#{title}\n#{"="*30}\n\n#{content}" end end |
#to_html ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/leandocument/render/re_structured_text.rb', line 3 def to_html html = RbST.new(exec_trans).to_html 6.times do |i| html = html.gsub("<h#{6 - i}", "<h#{5 - i + indent}").gsub("</h#{6 - i}>", "</h#{5 - i + indent}>") end html end |