Sha256: 74b21bdc762c9ec1addec600164455a9019a21f7053298c219f8668a35b7a831

Contents?: true

Size: 788 Bytes

Versions: 15

Compression:

Stored size: 788 Bytes

Contents

# encoding: utf-8

require 'systemu'

module Nanoc::Filters

  # @since 3.2.0
  class AsciiDoc < Nanoc::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

15 entries across 15 versions & 1 rubygems

Version Path
nanoc-3.5.0 lib/nanoc/filters/asciidoc.rb
nanoc-3.5.0b2 lib/nanoc/filters/asciidoc.rb
nanoc-3.5.0b1 lib/nanoc/filters/asciidoc.rb
nanoc-3.4.3 lib/nanoc/filters/asciidoc.rb
nanoc-3.4.2 lib/nanoc/filters/asciidoc.rb
nanoc-3.4.1 lib/nanoc/filters/asciidoc.rb
nanoc-3.4.0 lib/nanoc/filters/asciidoc.rb
nanoc-3.3.7 lib/nanoc/filters/asciidoc.rb
nanoc-3.3.6 lib/nanoc/filters/asciidoc.rb
nanoc-3.3.5 lib/nanoc/filters/asciidoc.rb
nanoc-3.3.4 lib/nanoc/filters/asciidoc.rb
nanoc-3.3.3 lib/nanoc/filters/asciidoc.rb
nanoc-3.3.2 lib/nanoc/filters/asciidoc.rb
nanoc-3.3.1 lib/nanoc/filters/asciidoc.rb
nanoc-3.3.0 lib/nanoc/filters/asciidoc.rb