Class: Xmindoc::Exporter
- Inherits:
-
Object
- Object
- Xmindoc::Exporter
- Defined in:
- lib/xmindoc/exporter.rb
Overview
Export a HTML to any filetypes with Pandoc Original Source: pandoc-ruby github.com/alphabetum/pandoc-ruby/blob/master/lib/pandoc-ruby.rb
Constant Summary collapse
- EXECUTABLES =
%W[ pandoc markdown2pdf html2markdown hsmarkdown ]
- @@bin_path =
nil
Instance Attribute Summary collapse
-
#html ⇒ Object
Returns the value of attribute html.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Class Method Summary collapse
Instance Method Summary collapse
- #execute(command) ⇒ Object
- #export ⇒ Object
-
#initialize(option, html = '') ⇒ Exporter
constructor
A new instance of Exporter.
Constructor Details
#initialize(option, html = '') ⇒ Exporter
Returns a new instance of Exporter.
29 30 31 32 33 34 35 |
# File 'lib/xmindoc/exporter.rb', line 29 def initialize(option, html='') @html = html @option = option @result = '' @executable = 'pandoc' print @target end |
Instance Attribute Details
#html ⇒ Object
Returns the value of attribute html.
14 15 16 |
# File 'lib/xmindoc/exporter.rb', line 14 def html @html end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
13 14 15 |
# File 'lib/xmindoc/exporter.rb', line 13 def result @result end |
Class Method Details
.bin_path=(path) ⇒ Object
25 26 27 |
# File 'lib/xmindoc/exporter.rb', line 25 def self.bin_path=(path) @@bin_path = path end |
Instance Method Details
#execute(command) ⇒ Object
55 56 57 58 59 60 61 62 63 |
# File 'lib/xmindoc/exporter.rb', line 55 def execute(command) output = '' Open3::popen3(command) do |stdin, stdout, stderr| stdin.puts @target stdin.close output = stdout.read.strip end output end |
#export ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/xmindoc/exporter.rb', line 37 def export() @target = @html executable = @@bin_path ? File.join(@@bin_path, @executable) : @executable = "--standalone --from #{@option[:format_from]} --to #{@option[:format_to]} #{@option[:pandoc_options]}" command = executable + " " + puts command if DEBUG @result = execute(command) # @converter = PandocRuby.new(@html, # :standalone, # :from => @option[:format_from], # :to => @option[:format_to]) # @result = @converter.convert return @result end |