Module: Doc2Text::Odt::XmlNodes::Text
- Included in:
- ListItem, P, Span
- Defined in:
- lib/doc2text/namespaces.rb
Defined Under Namespace
Classes: LineBreak, ListItem, P, Span
Instance Method Summary
collapse
Instance Method Details
#fetch_common_style(style) ⇒ Object
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
# File 'lib/doc2text/namespaces.rb', line 80
def fetch_common_style(style)
if style
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(style_name) ⇒ Object
96
97
98
99
100
101
|
# File 'lib/doc2text/namespaces.rb', line 96
def fetch_style(style_name)
styles = @markdown_document.xpath '/office:document-content/office:automatic-styles/style:style'
style = styles.find { |style| style.attrs.index { |attr| attr.prefix == 'style' && attr.localname == 'family' && attr.value == self.class.style_family } &&
style.attrs.index { |attr| attr.prefix == 'style' && attr.localname == 'name' && attr.value == style_name } }
fetch_common_style style
end
|
#initialize(parent = nil, attrs = [], prefix = nil, name = nil, markdown_document = nil) ⇒ Object
70
71
72
73
74
75
76
77
78
|
# File 'lib/doc2text/namespaces.rb', line 70
def initialize(parent = nil, attrs = [], prefix = nil, name = nil, markdown_document = nil)
super parent, attrs, prefix, name, markdown_document
@markdown_document = markdown_document
style_index = attrs.index { |attr| attr.prefix == 'text' && attr.localname == 'style-name' }
@enclosing_style = []
if style_index
fetch_style attrs[style_index].value
end
end
|