Sha256: 942aae1d7b92d71e38299dbb513d6f86026ad1b774405c76b34b899bfdd1c1f8

Contents?: true

Size: 1008 Bytes

Versions: 43

Compression:

Stored size: 1008 Bytes

Contents

# frozen_string_literal: true

module Nanoc::Filters
  # @api private
  class Kramdown < Nanoc::Filter
    identifier :kramdown

    requires 'kramdown'

    # Runs the content through [Kramdown](http://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
    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
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
nanoc-4.11.2 lib/nanoc/filters/kramdown.rb
nanoc-4.11.1 lib/nanoc/filters/kramdown.rb
nanoc-4.11.0 lib/nanoc/filters/kramdown.rb
nanoc-4.10.4 lib/nanoc/filters/kramdown.rb
nanoc-4.10.3 lib/nanoc/filters/kramdown.rb
nanoc-4.10.2 lib/nanoc/filters/kramdown.rb
nanoc-4.10.1 lib/nanoc/filters/kramdown.rb
nanoc-4.10.0 lib/nanoc/filters/kramdown.rb
nanoc-4.9.9 lib/nanoc/filters/kramdown.rb
nanoc-4.9.8 lib/nanoc/filters/kramdown.rb
nanoc-4.9.7 lib/nanoc/filters/kramdown.rb
nanoc-4.9.6 lib/nanoc/filters/kramdown.rb
nanoc-4.9.5 lib/nanoc/filters/kramdown.rb
nanoc-4.9.4 lib/nanoc/filters/kramdown.rb
nanoc-4.9.3 lib/nanoc/filters/kramdown.rb
nanoc-4.9.2 lib/nanoc/filters/kramdown.rb
nanoc-4.9.1 lib/nanoc/filters/kramdown.rb
nanoc-4.9.0 lib/nanoc/filters/kramdown.rb
nanoc-4.8.19 lib/nanoc/filters/kramdown.rb
nanoc-4.8.18 lib/nanoc/filters/kramdown.rb