class Doc2Text::Odt::Document

Public Class Methods

parse_and_save(input, output_filename) click to toggle source
# File lib/doc2text/odt/odt.rb, line 9
def self.parse_and_save(input, output_filename)
  odt = new input
  begin
    odt.unpack
    styles_xml_root = odt.parse_styles
    output = File.open output_filename, 'w'
    markdown = Markdown::OdtParser.new output, styles_xml_root
    begin
      odt.parse markdown
    ensure
      markdown.close
    end
  ensure
    odt.clean
  end
end

Public Instance Methods

contains_extracted_files?() click to toggle source
# File lib/doc2text/odt/odt.rb, line 38
def contains_extracted_files?
  [File.join(extract_path, 'content.xml'), File.join(extract_path, 'mimetype')].all? { |file| File.exist?(file) }
end
extract_extension() click to toggle source
# File lib/doc2text/odt/odt.rb, line 5
def extract_extension
  'unpacked_odt'
end
parse(markdown) click to toggle source
# File lib/doc2text/odt/odt.rb, line 33
def parse(markdown)
  parser = Nokogiri::XML::SAX::Parser.new(markdown) # { |config| config.strict}
  parser.parse open 'content.xml'
end
parse_styles() click to toggle source
# File lib/doc2text/odt/odt.rb, line 26
def parse_styles
  styles_parser = Doc2Text::Odt::StylesParser.new
  xml = Nokogiri::XML::SAX::Parser.new(styles_parser)
  xml.parse open 'styles.xml'
  styles_parser.xml_root
end