Sha256: 48cb9ef7d2432aacd2dcdfe69d244560d4a969c97ed84c8a1124f4c943ef44f1

Contents?: true

Size: 1009 Bytes

Versions: 47

Compression:

Stored size: 1009 Bytes

Contents

# frozen_string_literal: true

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

    requires 'kramdown'

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

47 entries across 47 versions & 1 rubygems

Version Path
nanoc-4.13.3 lib/nanoc/filters/kramdown.rb
nanoc-4.13.2 lib/nanoc/filters/kramdown.rb
nanoc-4.13.1 lib/nanoc/filters/kramdown.rb
nanoc-4.13.0 lib/nanoc/filters/kramdown.rb
nanoc-4.12.21 lib/nanoc/filters/kramdown.rb
nanoc-4.12.20 lib/nanoc/filters/kramdown.rb
nanoc-4.12.19 lib/nanoc/filters/kramdown.rb
nanoc-4.12.18 lib/nanoc/filters/kramdown.rb
nanoc-4.12.17 lib/nanoc/filters/kramdown.rb
nanoc-4.12.16 lib/nanoc/filters/kramdown.rb
nanoc-4.12.15 lib/nanoc/filters/kramdown.rb
nanoc-4.12.14 lib/nanoc/filters/kramdown.rb
nanoc-4.12.13 lib/nanoc/filters/kramdown.rb
nanoc-4.12.12 lib/nanoc/filters/kramdown.rb
nanoc-4.12.11 lib/nanoc/filters/kramdown.rb
nanoc-4.12.10 lib/nanoc/filters/kramdown.rb
nanoc-4.12.9 lib/nanoc/filters/kramdown.rb
nanoc-4.12.8 lib/nanoc/filters/kramdown.rb
nanoc-4.12.7 lib/nanoc/filters/kramdown.rb
nanoc-4.12.6 lib/nanoc/filters/kramdown.rb