Sha256: 9377024da4fa046d852486c90a1a62426d4b5f96bc1c9f50f6d72911c88767a1

Contents?: true

Size: 1.14 KB

Versions: 42

Compression:

Stored size: 1.14 KB

Contents

module Nanoc::Filters
  # @api private
  class Pandoc < Nanoc::Filter
    requires 'pandoc-ruby'

    # Runs the content through [Pandoc](http://johnmacfarlane.net/pandoc/)
    # using [PandocRuby](https://github.com/alphabetum/pandoc-ruby).
    #
    # Arguments can be passed to PandocRuby in two ways:
    #
    # * Use the `:args` option. This approach is more flexible, since it
    #   allows passing an array instead of a hash.
    #
    # * Pass the arguments directly to the filter. With this approach, only
    #   hashes can be passed, which is more limiting than the `:args` approach.
    #
    # The `:args` approach is recommended.
    #
    # @example Passing arguments using `:arg`
    #
    #     filter :pandoc, args: [:s, {:f => :markdown, :to => :html}, 'no-wrap', :toc]
    #
    # @example Passing arguments not using `:arg`
    #
    #     filter :pandoc, :f => :markdown, :to => :html
    #
    # @param [String] content The content to filter
    #
    # @return [String] The filtered content
    def run(content, params = {})
      args = params.key?(:args) ? params[:args] : params

      PandocRuby.convert(content, *args)
    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
nanoc-4.4.7 lib/nanoc/filters/pandoc.rb
nanoc-4.4.6 lib/nanoc/filters/pandoc.rb
nanoc-4.4.5 lib/nanoc/filters/pandoc.rb
nanoc-4.4.4 lib/nanoc/filters/pandoc.rb
nanoc-4.4.3 lib/nanoc/filters/pandoc.rb
nanoc-4.4.2 lib/nanoc/filters/pandoc.rb
nanoc-4.4.1 lib/nanoc/filters/pandoc.rb
nanoc-4.4.0 lib/nanoc/filters/pandoc.rb
nanoc-4.3.8 lib/nanoc/filters/pandoc.rb
nanoc-4.3.7 lib/nanoc/filters/pandoc.rb
nanoc-4.3.6 lib/nanoc/filters/pandoc.rb
nanoc-4.3.5 lib/nanoc/filters/pandoc.rb
nanoc-4.3.4 lib/nanoc/filters/pandoc.rb
nanoc-4.3.3 lib/nanoc/filters/pandoc.rb
nanoc-4.3.2 lib/nanoc/filters/pandoc.rb
nanoc-4.3.1 lib/nanoc/filters/pandoc.rb
nanoc-4.3.0 lib/nanoc/filters/pandoc.rb
nanoc-4.2.4 lib/nanoc/filters/pandoc.rb
nanoc-4.2.3 lib/nanoc/filters/pandoc.rb
nanoc-4.2.2 lib/nanoc/filters/pandoc.rb