Sha256: 54f8f6adc379670521d94f39b0b173c9320eb18bc3436bbbe06e94cb0dd35659

Contents?: true

Size: 625 Bytes

Versions: 3

Compression:

Stored size: 625 Bytes

Contents

module Mdoc
  # delegate output to pandoc (assume pandoc in path)
  class PandocWriter < Writer
    def out(doc)
      @tmp_file = doc.out_file ? doc.out_file + '.temp__' : ''
      Mdoc.opts.no_output ? $stdout : File.new(@tmp_file, 'wb')
    end

    def process!(doc)
      @tilt = Tilt::ERBTemplate.new(Mdoc.find_tpl_file('pandoc.md'))
      oh = out(doc)
      oh.write @tilt.render(doc)
      unless oh == $stdout
        oh.close
        `pandoc -o #{doc.out_file} #{@tmp_file}`
        File.delete @tmp_file
      end
    end

    def default_processors
      %w[smart_code_block
      expand_link]
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mdoc-0.0.11 lib/mdoc/writer/pandoc_writer.rb
mdoc-0.0.10 lib/mdoc/writer/pandoc_writer.rb
mdoc-0.0.9 lib/mdoc/writer/pandoc_writer.rb