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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZGRkOTkyMmQ0ZDBkMWRjNTNkMjc0MjRiODEyMDhkZmJhZjBkM2JkNQ==
4
+ YWJmNzViYjgxOGFkOTRkYWM2MzI1NDE0MDA0MTI2MzEzZWZkZmNhMA==
5
5
  data.tar.gz: !binary |-
6
- YWQzNTJlYzg1ZmUzNGY2YmNmYjY5M2Y3MGM1ZmQ1Y2NmNTRjZjQxMw==
6
+ OTM5YmI3NzFmYjcwOTkxMWUzNzMxMjI1NTdhZDljYzE4ZGYzZjhjYw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZTNmZmM3MTBmMjIwN2UwMGY2NTcwNzNjNWMyZWMxMmI1NDYzZjQ0ODVhYzUx
10
- ZTU2ZDJlNTY0MDYzNTU4ODI2MzJmNmZjNzA3MWNmZTJlNzQyMDU3ZDNiZjA5
11
- NGM0NjBhZDllNWZkODk1NzhmZGM2YWJkNDg2NDliMTdhYmNjMDM=
9
+ MWI1MWFmODExYTAxY2VjODQzNmQyODI4MDJmMmMxZTJlY2UxZDY0YWMyY2I3
10
+ YjA3ZDk3YTdiNTVjYjc3ZmMwOGViYTYwZDQwZTFlNzE5OGMzZDViY2VjNjc5
11
+ YTA1ODEzMjg5M2YzNzBmZmE0YTBmMmY0M2Y3YTQwYzVmOGMwYjU=
12
12
  data.tar.gz: !binary |-
13
- M2MwOTg0MmEwMDI4NGMyNzI2MTAzNDk4ODBlMTNlYTY4ZGQ3N2ZjMjQ2ZjM0
14
- MDIyZDVjNWNlNjc5ODM1ODEzN2I5ZjIzZWU0NjEzZWNhN2RiOTI4ZDQ2MTNi
15
- NzliOTFjNzRiYTBlNDA4M2ZkNmZiMmNhMGM1NDk0OTRlNTc5ZTM=
13
+ ZDE5OGQxYTRjNmE3NTE1ZGJmZjUzMGFmNWRlZjdhNGMzYWJlOTFkYzEyMzJk
14
+ ZTkyNzUwYWYyMTMwYTQ2YWIzYWVmMzEzNzE2MTg1ODBkMmM2ZmI1MzZiM2Ri
15
+ MzE5Mjc4MjUyMzk0NzMzZWNlZWVlYmM1ZTFiMGY1YjhkYjY0ZTc=
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swordfish
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Posthumus