Class: Doc2Text::Odt::Document
Class Method Summary
collapse
Instance Method Summary
collapse
#clean, #extract_path, #initialize, #open, #unpack
Class Method Details
.parse_and_save(input, output_filename) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# 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
|
Instance Method Details
38
39
40
|
# File 'lib/doc2text/odt/odt.rb', line 38
def
[File.join(, 'content.xml'), File.join(, 'mimetype')].all? { |file| File.exist?(file) }
end
|
5
6
7
|
# File 'lib/doc2text/odt/odt.rb', line 5
def
'unpacked_odt'
end
|
#parse(markdown) ⇒ Object
33
34
35
36
|
# File 'lib/doc2text/odt/odt.rb', line 33
def parse(markdown)
parser = Nokogiri::XML::SAX::Parser.new(markdown) parser.parse open 'content.xml'
end
|
#parse_styles ⇒ Object
26
27
28
29
30
31
|
# 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
|