class Nanoc::Filters::Kramdown

@api private

Public Instance Methods

run(content, params = {}) click to toggle source

Runs the content through [Kramdown](kramdown.gettalong.org/). Parameters passed to this filter will be passed on to Kramdown.

@param [String] content The content to filter

@return [String] The filtered content

# File lib/nanoc/filters/kramdown.rb, line 16
def run(content, params = {})
  params = params.dup
  warning_filters = params.delete(:warning_filters)
  document = ::Kramdown::Document.new(content, params)

  if warning_filters
    r = Regexp.union(warning_filters)
    warnings = document.warnings.reject { |warning| r =~ warning }
  else
    warnings = document.warnings
  end

  if warnings.any?
    $stderr.puts "kramdown warning(s) for #{@item_rep.inspect}"
    warnings.each do |warning|
      $stderr.puts "  #{warning}"
    end
  end

  document.to_html
end