Sha256: e93aa5da79de4a009907a6c4eea82ae4a05875c88c482d2395d22bdfac9a1d1b

Contents?: true

Size: 422 Bytes

Versions: 2

Compression:

Stored size: 422 Bytes

Contents

module MarkitupHelper
  def markdown(text)
    options = [:hard_wrap, :filter_html, :autolink, :no_intraemphasis, :fenced_code, :gh_blockcode]
    syntax_highlighter(Redcarpet.new(text, *options).to_html).html_safe
  end

  def syntax_highlighter(html)
    doc = Nokogiri::HTML(html)
    doc.search("//pre[@lang]").each do |pre|
      pre.replace Albino.colorize(pre.text.rstrip, pre[:lang])
    end
    doc.to_s
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rails_markitup-0.0.2 app/helpers/rails_markitup/markitup_helper.rb
rails_markitup-0.0.1 app/helpers/rails_markitup/markitup_helper.rb