Commit 813e6826 authored by Michael Witrant's avatar Michael Witrant

use paragraph styles

parent e208ef33
......@@ -21,6 +21,14 @@ class AmendmentExtractor
STDERR.puts output
end
end
def style_weight(style_name)
if @styles[style_name] and @styles[style_name][:bold]
:bold
else
:normal
end
end
def extract(opendocument_path, options = {})
debug "extracting content from document"
......@@ -52,6 +60,7 @@ class AmendmentExtractor
styles[name] = style
end
@styles = styles
debug "extracting document text"
......@@ -116,15 +125,16 @@ class AmendmentExtractor
text_table = table.css("table|table-row").map do |row|
row.css("table|table-cell").map do |cell|
cell.css("text|p").map do |paragraph|
style_name = paragraph["text:style-name"]
paragraph_style = style_name ? style_weight(style_name) : :normal
parts = paragraph.children.map do |element|
text = element.text
style = :normal
style = paragraph_style
if text.present? and element.is_a? Nokogiri::XML::Element
style_name = element["text:style-name"]
if style_name and styles[style_name][:bold]
style = :bold
end
style = style_weight(style_name) if style_name
end
[style, text]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment