Class: DocxConverter::Parser
- Inherits:
-
Object
- Object
- DocxConverter::Parser
- Defined in:
- lib/docx_converter/parser.rb
Instance Method Summary collapse
-
#initialize(options) ⇒ Parser
constructor
A new instance of Parser.
- #parse ⇒ Object
Constructor Details
#initialize(options) ⇒ Parser
Returns a new instance of Parser.
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/docx_converter/parser.rb', line 22 def initialize() @output_dir = [:output_dir] @docx_filepath = [:inputfile] @image_subdir_filesystem = [:image_subdir_filesystem] @image_subdir_kramdown = [:image_subdir_kramdown] @relationships_hash = {} @zipfile = Zip::ZipFile.new(@docx_filepath) end |
Instance Method Details
#parse ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/docx_converter/parser.rb', line 34 def parse document_xml = unzip_read("word/document.xml") footnotes_xml = unzip_read("word/footnotes.xml") relationships_xml = unzip_read("word/_rels/document.xml.rels") content = Nokogiri::XML(document_xml) footnotes = Nokogiri::XML(footnotes_xml) relationships = Nokogiri::XML(relationships_xml) @relationships_hash = parse_relationships(relationships) footnote_definitions = parse_footnotes(footnotes) output_content = parse_content(content.elements.first,0) return { :content => output_content, :footnote_definitions => footnote_definitions } end |