swordfish 0.0.10 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/lib/swordfish/document.rb +9 -0
- data/lib/swordfish/formats/docx/parser.rb +5 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YWJmNzViYjgxOGFkOTRkYWM2MzI1NDE0MDA0MTI2MzEzZWZkZmNhMA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OTM5YmI3NzFmYjcwOTkxMWUzNzMxMjI1NTdhZDljYzE4ZGYzZjhjYw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MWI1MWFmODExYTAxY2VjODQzNmQyODI4MDJmMmMxZTJlY2UxZDY0YWMyY2I3
|
10
|
+
YjA3ZDk3YTdiNTVjYjc3ZmMwOGViYTYwZDQwZTFlNzE5OGMzZDViY2VjNjc5
|
11
|
+
YTA1ODEzMjg5M2YzNzBmZmE0YTBmMmY0M2Y3YTQwYzVmOGMwYjU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZDE5OGQxYTRjNmE3NTE1ZGJmZjUzMGFmNWRlZjdhNGMzYWJlOTFkYzEyMzJk
|
14
|
+
ZTkyNzUwYWYyMTMwYTQ2YWIzYWVmMzEzNzE2MTg1ODBkMmM2ZmI1MzZiM2Ri
|
15
|
+
MzE5Mjc4MjUyMzk0NzMzZWNlZWVlYmM1ZTFiMGY1YjhkYjY0ZTc=
|
data/lib/swordfish/document.rb
CHANGED
@@ -64,6 +64,7 @@ module Swordfish
|
|
64
64
|
def settings(opts = {})
|
65
65
|
find_headers! if opts[:guess_headers]
|
66
66
|
find_footnotes! if opts[:footnotes]
|
67
|
+
clean_line_breaks! if opts[:smart_br]
|
67
68
|
@generate_full_document = !!opts[:full_document]
|
68
69
|
self
|
69
70
|
end
|
@@ -130,5 +131,13 @@ module Swordfish
|
|
130
131
|
end
|
131
132
|
end
|
132
133
|
|
134
|
+
# Remove superfluous linebreaks
|
135
|
+
def clean_line_breaks!
|
136
|
+
find_nodes_by_type(Swordfish::Node::Paragraph).each do |paragraph|
|
137
|
+
paragraph.children.delete_at(0) if paragraph.children.first.is_a?(Swordfish::Node::Linebreak)
|
138
|
+
paragraph.children.delete_at(-1) if paragraph.children.last.is_a?(Swordfish::Node::Linebreak)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
133
142
|
end
|
134
143
|
end
|
@@ -19,6 +19,11 @@ module Swordfish
|
|
19
19
|
nodes.each_with_index do |run_xml, idx|
|
20
20
|
case run_xml.name
|
21
21
|
when 'r'
|
22
|
+
if run_xml.xpath('./w:br').length > 0
|
23
|
+
# This run contains a linebreak. It may also contain other elements, so this isn't exclusive.
|
24
|
+
texts << Swordfish::Node::Linebreak.new
|
25
|
+
end
|
26
|
+
|
22
27
|
if run_xml.xpath('./w:t').length > 0 && complex_field.nil?
|
23
28
|
# A True run node
|
24
29
|
# Only examine the run if it includes text codes. The run may also include
|
@@ -74,9 +79,6 @@ module Swordfish
|
|
74
79
|
# An endnote reference
|
75
80
|
id = run_xml.xpath('./w:endnoteReference')[0]['w:id'].to_i
|
76
81
|
texts << @endnotes[id] if @endnotes[id]
|
77
|
-
elsif run_xml.xpath('./w:br').length > 0
|
78
|
-
# A linebreak run
|
79
|
-
texts << Swordfish::Node::Linebreak.new
|
80
82
|
end
|
81
83
|
when 'hyperlink'
|
82
84
|
# Hyperlink nodes are placed amongst other run nodes, but
|