Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
LQDN Adminsys
amendments
Commits
9929d956
Commit
9929d956
authored
Mar 31, 2013
by
Michael Witrant
Browse files
use real style to make bold
parent
2618e50a
Changes
1
Hide whitespace changes
Inline
Side-by-side
extract_amendments.rb
View file @
9929d956
...
...
@@ -31,6 +31,18 @@ if xml_dump_path
File
.
open
(
xml_dump_path
,
"w"
)
{
|
f
|
f
.
write
doc
.
to_xml
(
indent:
2
)
}
end
styles
=
{}
doc
.
css
(
"style|style"
).
each
do
|
node
|
name
=
node
[
"style:name"
]
style
=
{}
text_properties
=
node
.
css
(
"style|text-properties"
).
first
if
text_properties
style
[
:bold
]
=
(
text_properties
[
"fo:font-weight"
]
==
"bold"
)
end
styles
[
name
]
=
style
end
text
=
doc
.
xpath
(
'//office:text'
).
first
raise
"no office:text found"
unless
text
...
...
@@ -84,11 +96,16 @@ amend_nodes.each do |nodes|
row
.
css
(
"table|table-cell"
).
map
do
|
cell
|
cell
.
css
(
"text|p"
).
map
do
|
paragraph
|
paragraph
.
children
.
map
do
|
element
|
text
=
element
.
text
if
element
.
is_a?
Nokogiri
::
XML
::
Element
and
element
.
name
==
'span'
"'''
#{
element
.
text
}
'''"
else
element
.
text
style_name
=
element
[
"text:style-name"
]
if
style_name
and
styles
[
style_name
][
:bold
]
text
=
"'''
#{
text
}
'''"
end
end
text
end
.
join
end
.
join
(
"
\n
"
)
end
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment