Sha256: a16ec3d3bf5aef62375e0688cc8961dbc29a5561cd072a77a56885c53be3b144
Contents?: true
Size: 1.42 KB
Versions: 5
Compression:
Stored size: 1.42 KB
Contents
module Markdown module Engine def redcarpet_to_html( content, options={} ) ## NB: uses redcarpet2 # # see https://github.com/tanoku/redcarpet extensions_ary = options.fetch( 'extensions', [] ) extensions_hash = {} extensions_ary.each do |e| extensions_hash[ e.to_sym ] = true end puts " Converting Markdown-text (#{@content.length} bytes) to HTML using library redcarpet (#{Redcarpet::VERSION}) w/ HTML render" puts " using extensions: [#{extensions_ary.join(', ')}]" redcarpet = Redcarpet::Markdown.new( Redcarpet::Render::HTML, extensions_hash ) content = redcarpet.render( content ) # todo: check content size and newlines # check banner option? # only add banner if some newlines and size > treshold? banner_begin =<<EOS <!-- === begin markdown block ===================================================== generated by #{Markdown.banner} on #{Time.now} with Markdown engine redcarpet (#{Redcarpet::VERSION}) w/ HTML render using extensions: [#{extensions_ary.join(', ')}] --> EOS banner_end =<<EOS <!-- === end markdown block ===================================================== --> EOS content = banner_begin + content + banner_end end end # module Engine end # module Markdown
Version data entries
5 entries across 5 versions & 1 rubygems