Sha256: a47739c978b4a369a58b24450a447a1aecaa21a0e9298117e8526321b87449b2

Contents?: true

Size: 710 Bytes

Versions: 12

Compression:

Stored size: 710 Bytes

Contents

module Leandocument
  class Markdown < Render
    def to_html
      RDiscount.new(exec_trans).to_html
    end
    
    # Convert to something from content.
    # Currently, Change indent level.
    # TODO support plugin and expand format.
    # ==== Return
    # Text content.
    def exec_trans
      content = indented_content
      content = content.gsub(/^!\[(.*)\]\((.*)\)/, '![\\1]('+self.path+'\\2)') # For image
    end
    
    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
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
leandocument-0.1.0 lib/leandocument/render/markdown.rb
leandocument-0.0.11 lib/leandocument/render/markdown.rb
leandocument-0.0.10 lib/leandocument/render/markdown.rb
leandocument-0.0.9 lib/leandocument/render/markdown.rb
leandocument-0.0.8 lib/leandocument/render/markdown.rb
leandocument-0.0.7 lib/leandocument/render/markdown.rb
leandocument-0.0.6 lib/leandocument/render/markdown.rb
leandocument-0.0.5 lib/leandocument/render/markdown.rb
leandocument-0.0.4 lib/leandocument/render/markdown.rb
leandocument-0.0.3 lib/leandocument/render/markdown.rb
leandocument-0.0.2 lib/leandocument/render/markdown.rb
leandocument-0.0.1 lib/leandocument/render/markdown.rb