Sha256: 008b0f9be8155ad98c1519e7bdc0d617f673917a15a03a5546380d3d9f13a637

Contents?: true

Size: 1.19 KB

Versions: 17

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

module Nanoc::Filters
  # @api private
  class Pandoc < Nanoc::Filter
    identifier :pandoc

    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

17 entries across 17 versions & 1 rubygems

Version Path
nanoc-4.8.11 lib/nanoc/filters/pandoc.rb
nanoc-4.8.10 lib/nanoc/filters/pandoc.rb
nanoc-4.8.9 lib/nanoc/filters/pandoc.rb
nanoc-4.8.8 lib/nanoc/filters/pandoc.rb
nanoc-4.8.7 lib/nanoc/filters/pandoc.rb
nanoc-4.8.6 lib/nanoc/filters/pandoc.rb
nanoc-4.8.5 lib/nanoc/filters/pandoc.rb
nanoc-4.8.4 lib/nanoc/filters/pandoc.rb
nanoc-4.8.3 lib/nanoc/filters/pandoc.rb
nanoc-4.8.2 lib/nanoc/filters/pandoc.rb
nanoc-4.8.1 lib/nanoc/filters/pandoc.rb
nanoc-4.8.0 lib/nanoc/filters/pandoc.rb
nanoc-4.7.14 lib/nanoc/filters/pandoc.rb
nanoc-4.7.13 lib/nanoc/filters/pandoc.rb
nanoc-4.7.12 lib/nanoc/filters/pandoc.rb
nanoc-4.7.11 lib/nanoc/filters/pandoc.rb
nanoc-4.7.10 lib/nanoc/filters/pandoc.rb