module Doc2Text::Odt::XmlNodes::Text
Public Class Methods
Source
# File lib/doc2text/odt/odt_xml_namespaces.rb, line 88 def initialize(parent = nil, attrs = [], prefix = nil, name = nil, markdown_odt_parser = nil) super parent, attrs, prefix, name @xml_parser = markdown_odt_parser style_index = attrs.index { |attr| attr.prefix == 'text' && attr.localname == 'style-name' } @enclosing_style = [] if style_index and fetch_style? elem_style = find_style attrs[style_index].value fetch_style elem_style end end
Calls superclass method
Public Instance Methods
Source
# File lib/doc2text/odt/odt_xml_namespaces.rb, line 103 def fetch_style(elem_style) if elem_style elem_style.children.select { |style_property| style_property.xml_name == 'style:text-properties' }.each { |text_property| text_property.attrs.each { |attr| if attr.prefix == 'style' if attr.localname == 'font-style-complex' && attr.value == 'italic' @enclosing_style << '_' elsif attr.localname == 'font-weight-complex' && attr.value == 'bold' @enclosing_style << '**' end end } } end end
Source
# File lib/doc2text/odt/odt_xml_namespaces.rb, line 99 def fetch_style? true end
Source
# File lib/doc2text/odt/odt_xml_namespaces.rb, line 119 def find_style(style_name) styles = @xml_parser.xpath '/office:document-content/office:automatic-styles/style:style' styles.find { |style| style.attrs.index { |attr| attr.prefix == 'style' && attr.localname == 'family' } && style.attrs.index { |attr| attr.prefix == 'style' && attr.localname == 'name' && attr.value == style_name } } end