Module: Coradoc::Input::Docx

Defined in:
lib/coradoc/input/docx.rb

Class Method Summary collapse

Class Method Details

.processor_execute(input, options = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/coradoc/input/docx.rb', line 15

def self.processor_execute(input, options = {})
  image_dir = Dir.mktmpdir
  options = options.merge(sourcedir: image_dir)
  doc = WordToMarkdown.new(input, image_dir)
  doc = Coradoc::Input::HTML.cleaner.preprocess_word_html(doc.document.html)
  options = WordToMarkdown::REVERSE_MARKDOWN_OPTIONS.merge(options)
  Coradoc::Input::HTML.to_coradoc(doc, options)
ensure
  FileUtils.rm_rf(image_dir)
end

.processor_idObject



7
8
9
# File 'lib/coradoc/input/docx.rb', line 7

def self.processor_id
  :docx
end

.processor_match?(filename) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/coradoc/input/docx.rb', line 11

def self.processor_match?(filename)
  %w[.docx .doc].any? { |i| filename.downcase.end_with?(i) }
end

.processor_postprocess(data, options) ⇒ Object



26
27
28
# File 'lib/coradoc/input/docx.rb', line 26

def self.processor_postprocess(data, options)
  Coradoc::Input::HTML.processor_postprocess(data, options)
end

.processor_wants_filenamesObject

This processor prefers to work on original files.



31
# File 'lib/coradoc/input/docx.rb', line 31

def self.processor_wants_filenames; true; end