Module: Doc2Text::Odt::XmlNodes::Text
Defined Under Namespace
Classes: LineBreak, List, ListItem, P, Span
Instance Method Summary
collapse
Instance Method Details
#fetch_style(elem_style) ⇒ Object
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
# File 'lib/doc2text/odt_xml_namespaces.rb', line 124
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
|
#fetch_style? ⇒ Boolean
120
121
122
|
# File 'lib/doc2text/odt_xml_namespaces.rb', line 120
def fetch_style?
true
end
|
#find_style(style_name) ⇒ Object
140
141
142
143
144
|
# File 'lib/doc2text/odt_xml_namespaces.rb', line 140
def find_style(style_name)
styles = @markdown_odt_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
|
#initialize(parent = nil, attrs = [], prefix = nil, name = nil, markdown_odt_parser = nil) ⇒ Object
109
110
111
112
113
114
115
116
117
118
|
# File 'lib/doc2text/odt_xml_namespaces.rb', line 109
def initialize(parent = nil, attrs = [], prefix = nil, name = nil, markdown_odt_parser = nil)
super parent, attrs, prefix, name
@markdown_odt_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
|