Sha256: 34b75f2951acededdb899a73b22e73cfbb3724b2d410ae43c4b82f4cd2a8846e

Contents?: true

Size: 793 Bytes

Versions: 8

Compression:

Stored size: 793 Bytes

Contents

# encoding: utf-8

module Nanoc::Filters

  # @since 3.2.0
  class AsciiDoc < Nanoc::Filter

    requires 'systemu'

    # Runs the content through [AsciiDoc](http://www.methods.co.nz/asciidoc/).
    # This method takes no options.
    #
    # @param [String] content The content to filter
    #
    # @return [String] The filtered content
    def run(content, params={})
      # Run command
      stdout = ''
      stderr = ''
      status = systemu(
        [ 'asciidoc', '-o', '-', '-' ],
        'stdin'  => content,
        'stdout' => stdout,
        'stderr' => stderr)

      # Show errors
      unless status.success?
        $stderr.puts stderr
        raise RuntimeError, "AsciiDoc filter failed with status #{status}"
      end

      # Get result
      stdout
    end

  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
nanoc-3.6.7 lib/nanoc/filters/asciidoc.rb
nanoc-3.6.6 lib/nanoc/filters/asciidoc.rb
nanoc-3.6.5 lib/nanoc/filters/asciidoc.rb
nanoc-3.6.4 lib/nanoc/filters/asciidoc.rb
nanoc-3.6.3 lib/nanoc/filters/asciidoc.rb
nanoc-3.6.2 lib/nanoc/filters/asciidoc.rb
nanoc-3.6.1 lib/nanoc/filters/asciidoc.rb
nanoc-3.6.0 lib/nanoc/filters/asciidoc.rb