Sha256: 7f06918fba2eae1d8db236584d799bef8348c80e42d571736ed72a5492351f42

Contents?: true

Size: 571 Bytes

Versions: 1

Compression:

Stored size: 571 Bytes

Contents

require 'thor'
require 'markyboot'

module Markyboot
  class CLI < Thor

    desc "preview FILE", "Convert a Markdown document and open it in the default browser."
    def preview(file = nil)
      raise "No file specified" if file.nil?

      content = File.read(file)
      html = Markyboot::Document.new(content).render

      begin
        preview = File.new('/tmp/preview.html', 'w')
        preview.write html
        system %Q{open #{preview.path}}
        puts "#{preview.path} opened in browser."
      ensure
        preview.close
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
markyboot-0.0.1 lib/markyboot/cli.rb