uniword 1.7.5 → 1.7.6

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,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d9c89b0b073e230af38b710f58a44d1f9018d1ae8c55f759ac7fcdefd7b3616c
4
- data.tar.gz: 38583e3f00b918f4749f5edbc5c6bdd00f56288ddeea09264656142b1ed34bc4
3
+ metadata.gz: 1f78e4ec92cc4ea7740d9e2ec0d3b2acf76ef1851331be34219795c902ebf090
4
+ data.tar.gz: e722b7c3c0b32d87477e727f4f6eeea54c3a766d5d9593d18b6f3698949fc4f5
5
5
  SHA512:
6
- metadata.gz: 88402c903c17f8828d18bf3134f5b7b974e23c611a4b25e03273f416787797f3ee8cf836513ddfbcbd7c9cd165d0905cdcb766243babaa448caa4ca0679de576
7
- data.tar.gz: 9a8533f5ab5fbfbde3171bc74cefbd628a333ca44cf3382dd3680db7d45b9926664d7e0d043fff12c8a53dd631a72621e52cbc6199b6fc4175188cd73167cdd9
6
+ metadata.gz: 3c34a8c5593579f138e64e36ee04f7cd4e8a0fcd6088c7f4d522bc9efdffb6f22c3ceb89d44a0b5e7d64508fad54df2ac856dbd220b8fb989fef3ed635d43b0d
7
+ data.tar.gz: 2eba230eaeffd07d2c30227c81fe4263dabff15f0802df553c42da0062a865283fe8a33fc0ba777b574aa9e5f454a59c3f06323f6a9953994117cc573b578e3e
@@ -270,16 +270,55 @@ document_name = nil)
270
270
  # Build HTML body content from sections array.
271
271
  # Each section is wrapped in a <div class=WordSectionN> with <br> between them.
272
272
  def build_sections_html(sections)
273
- return "" if sections.empty?
273
+ return footnote_list_html if sections.empty?
274
+
275
+ body = if sections.size == 1
276
+ elements_html = sections.first.map do |element|
277
+ @element_renderer.element_to_html(element)
278
+ end.join("\n")
279
+ "<div class=WordSection1>\n\n#{elements_html}\n\n</div>"
280
+ else
281
+ section_divs(sections)
282
+ end
283
+
284
+ body + footnote_list_html
285
+ end
274
286
 
275
- # Single section: wrap in WordSection1 without breaks
276
- if sections.size == 1
277
- elements_html = sections.first.map do |element|
278
- @element_renderer.element_to_html(element)
279
- end.join("\n")
280
- return "<div class=WordSection1>\n\n#{elements_html}\n\n</div>"
287
+ # Word MHTML carries footnote bodies at the end of the document body,
288
+ # wrapped in a footnote-list container; the in-text footnote
289
+ # references point at these blocks. Without this section the MHTML
290
+ # output silently loses every footnote body that the DOCX output
291
+ # keeps in word/footnotes.xml.
292
+ def footnote_list_html
293
+ entries = footnote_entries
294
+ return "" if entries.empty?
295
+
296
+ blocks = entries.map { |entry| footnote_entry_to_html(entry) }
297
+ "<div style='mso-element:footnote-list'>\n#{blocks.join("\n")}\n</div>"
298
+ end
299
+
300
+ # User footnote entries, in document order. The separator and
301
+ # continuationSeparator entries are Word plumbing, not content.
302
+ def footnote_entries
303
+ footnotes = @document.footnotes
304
+ return [] unless footnotes.is_a?(Uniword::Wordprocessingml::Footnotes)
305
+
306
+ footnotes.footnote_entries.reject do |entry|
307
+ entry.type == "separator" || entry.type == "continuationSeparator"
281
308
  end
309
+ end
310
+
311
+ def footnote_entry_to_html(entry)
312
+ html = Array(entry.paragraphs).map do |paragraph|
313
+ @element_renderer.paragraph_to_html(paragraph)
314
+ end.join("\n")
315
+
316
+ "<div style='mso-element:footnote' id=\"ftn#{entry.id}\">\n#{html}\n</div>"
317
+ end
318
+
319
+ private
282
320
 
321
+ def section_divs(sections)
283
322
  section_divs = sections.each_with_index.map do |section_elements, idx|
284
323
  elements_html = section_elements.map do |element|
285
324
  @element_renderer.element_to_html(element)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uniword
4
- VERSION = "1.7.5"
4
+ VERSION = "1.7.6"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uniword
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.5
4
+ version: 1.7.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-11-10 00:00:00.000000000 Z
11
+ date: 2026-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logger