Sha256: 3b34a688e48ea1044f479742fdba52ba16fe950b1e85b02d801ab6d28a0dd971

Contents?: true

Size: 790 Bytes

Versions: 8

Compression:

Stored size: 790 Bytes

Contents

# encoding: utf-8

require 'systemu'

module Nanoc3::Filters

  # @since 3.2.0
  class AsciiDoc < Nanoc3::Filter

    # 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
nanoc3-3.2.4 lib/nanoc3/filters/asciidoc.rb
nanoc3-3.2.3 lib/nanoc3/filters/asciidoc.rb
nanoc3-3.2.2 lib/nanoc3/filters/asciidoc.rb
nanoc3-3.2.1 lib/nanoc3/filters/asciidoc.rb
nanoc3-3.2.0 lib/nanoc3/filters/asciidoc.rb
nanoc3-3.2.0b3 lib/nanoc3/filters/asciidoc.rb
nanoc3-3.2.0b2 lib/nanoc3/filters/asciidoc.rb
nanoc3-3.2.0b1 lib/nanoc3/filters/asciidoc.rb