Sha256: a622a097601da60f8db3896ad5360e118d22dc23ad430463d1e927af5e6c19df
Contents?: true
Size: 732 Bytes
Versions: 2
Compression:
Stored size: 732 Bytes
Contents
class TextUtils::Markdown < TextUtils::Processor DEFAULT_OPTIONS = [:autolink, :lax_htmlblock, :smart, :tables, :xhtml, :fenced_code, :strikethrough, :hard_wrap] def initialize processor = nil, options = nil super processor @options = options || DEFAULT_OPTIONS end def call data, env if env[:format] == :markdown require 'redcarpet' data = fix_new_lines data do |data| markdown = Redcarpet.new(data, *@options) markdown.to_html end end call_next data, env end protected # remove line breaks after images def fix_new_lines data, &block data = block.call data data.gsub /(<img.+?\/>)\s*(<br\s*\/>)\s*\n/ do $1 end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rad_kit-0.0.10 | lib/text_utils/markdown.rb |
rad_kit-0.0.9 | lib/text_utils/markdown.rb |