Commit e208ef33 authored by Michael Witrant's avatar Michael Witrant
Browse files

merge contiguous styles

parent def5b42f
...@@ -116,19 +116,40 @@ class AmendmentExtractor ...@@ -116,19 +116,40 @@ class AmendmentExtractor
text_table = table.css("table|table-row").map do |row| text_table = table.css("table|table-row").map do |row|
row.css("table|table-cell").map do |cell| row.css("table|table-cell").map do |cell|
cell.css("text|p").map do |paragraph| cell.css("text|p").map do |paragraph| do |element| parts = do |element|
text = element.text text = element.text
style = :normal
# add mediawiki triple quote if the text is bold in the document if text.present? and element.is_a? Nokogiri::XML::Element
if element.is_a? Nokogiri::XML::Element and == 'span'
style_name = element["text:style-name"] style_name = element["text:style-name"]
if style_name and styles[style_name][:bold] if style_name and styles[style_name][:bold]
text = "'''#{text}'''" style = :bold
end end
end end
text [style, text]
# merge contiguous styles
result = []
last_style = nil
parts.each do |style, text|
if style == last_style
result.last[1] += text
result << [style, text]
result = do |style, text|
case style
when :bold
end.join end.join
end.join("\n") end.join("\n")
end end
end end
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