Module: MarkitupHelper
- Defined in:
- app/helpers/rails_markitup/markitup_helper.rb
Instance Method Summary collapse
Instance Method Details
#markdown(text) ⇒ Object
2 3 4 5 |
# File 'app/helpers/rails_markitup/markitup_helper.rb', line 2 def markdown(text) = [:hard_wrap, :filter_html, :autolink, :no_intraemphasis, :fenced_code, :gh_blockcode] syntax_highlighter(Redcarpet.new(text, *).to_html).html_safe end |
#syntax_highlighter(html) ⇒ Object
7 8 9 10 11 12 13 |
# File 'app/helpers/rails_markitup/markitup_helper.rb', line 7 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 |