Sha256: 1ff81f588e3223cbff9a1a6920572d6b34e2ec079bfa29e7d9c57518f0c5e1c6
Contents?: true
Size: 1.72 KB
Versions: 3
Compression:
Stored size: 1.72 KB
Contents
require 'redcarpet' require 'rouge' require 'rouge/plugins/redcarpet' module PersonalBlog module ApplicationHelper class HTML < Redcarpet::Render::HTML include Rouge::Plugins::Redcarpet def rouge_formatter(opts={}) opts = { inline_theme: nil } Rouge::Formatters::HTML.new(opts) end end def markdown(text) render_options = { filter_html: true, hard_wrap: true, link_attributes: { rel: 'nofollow', target: "_blank" }, space_after_headers: true, fenced_code_blocks: true, } extensions = { autolink: true, superscript: true, no_intra_emphasis: true, lax_spacing: true, strikethrough: true, fenced_code_blocks: true, disable_indented_code_blocks: true } renderer = HTML.new(render_options) markdown = Redcarpet::Markdown.new(renderer, extensions) markdown.render(text).html_safe end # class CodeRayify < Redcarpet::Render::HTML # def block_code(code, language) # CodeRay.scan(code, language).div # end # end # # def markdown(text) # coderayified = CodeRayify.new(filter_html: true, # hard_wrap: true) # options = { # fenced_code_blocks: true, # no_intra_emphasis: true, # autolink: true, # strikethrough: true, # lax_html_blocks: true, # superscript: true, # hardwrap: true # } # markdown_to_html = Redcarpet::Markdown.new(coderayified, options) # markdown_to_html.render(text).html_safe # end end end
Version data entries
3 entries across 3 versions & 1 rubygems