class UltraMarkdown::MarkdownProcessor

Public Class Methods

compile(raw) click to toggle source
# File lib/ultra_markdown.rb, line 47
def self.compile(raw)
  self.instance.format(raw)
end
compile_for_rss(raw) click to toggle source
# File lib/ultra_markdown.rb, line 51
def self.compile_for_rss(raw)
  self.instance.format(raw, true)
end
new() click to toggle source
# File lib/ultra_markdown.rb, line 32
def initialize
  options = {
    :autolink => true,
    :strikethrough => true,
    :space_after_headers => false,
    :tables => true,
    :lax_spacing => true,
    :no_intra_emphasis => true,
    :footnotes => true
  }

  @converter = Redcarpet::Markdown.new(HTMLforPost.new, options)
  @converter_for_rss = Redcarpet::Markdown.new(HTMLforRSS.new, options)
end

Public Instance Methods

format(raw, is_rss = false) click to toggle source
# File lib/ultra_markdown.rb, line 56
def format(raw, is_rss = false)
  text = raw.clone
  return '' if text.blank?

  result = if is_rss
    @converter_for_rss.render(text)
  else
    @converter.render(text)
  end

  #result = Modules::ResultSanitize.clean(result)

  doc = Nokogiri::HTML.fragment(result)

  return doc.to_html
rescue => e
  Airbrake.notify(e)
  puts "MarkdownTopicConverter.format ERROR: #{e}"
  return text
end