Class: Nanoc::Filters::Kramdown Private

Inherits:
Nanoc::Filter
  • Object
show all
Defined in:
lib/nanoc/filters/kramdown.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#run(content, params = {}) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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

Parameters:

  • content (String)

    The content to filter

Returns:

  • (String)

    The filtered content



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# 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