root/trunk/lib/picolena/templates/lib/plain_text_extractors/opendocument.text.rb

Revision 178, 459 bytes (checked in by eric.dumin..@gmail.com, 6 months ago)

Filters have been renamed to PlainTextExtractors?.

Filter is a Rails protected name.

  • Property svn:executable set to *
Line 
1 # Open Document to text conversion
2
3 require 'zip/zip'
4 PlainTextExtractor.new {
5   every :odt
6   as 'application/vnd.oasis.opendocument.text'
7   aka "Open Document Format for text"
8   with {|source|
9     Zip::ZipFile.open(source){|zipfile|
10       zipfile.read("content.xml").split(/</).grep(/^text:(p|span)/).collect{|l|
11         l.sub(/^[^>]+>/,'')
12       }.join("\n")
13     }
14   }
15   which_should_for_example_extract 'written with OpenOffice.org', :from => 'basic.odt'
16 }
Note: See TracBrowser for help on using the browser.