Skip to content

Add ability to read document footers (original work by @Jawad79Ahmad in #153)#174

Merged
satoryu merged 1 commit into
masterfrom
add-footer-extraction
May 31, 2026
Merged

Add ability to read document footers (original work by @Jawad79Ahmad in #153)#174
satoryu merged 1 commit into
masterfrom
add-footer-extraction

Conversation

@satoryu
Copy link
Copy Markdown
Member

@satoryu satoryu commented May 31, 2026

Summary

Adds the ability to read document footers (word/footer*.xml) via a new Docx::Document#footers accessor. Footers are exposed as a Hash keyed by the footer file name (e.g. "footer1"), with each value being a parsed Nokogiri::XML document.

doc = Docx::Document.open("with_footer.docx")
doc.footers["footer1"].text  # => "Hello from the footer."

This is the footer counterpart to the headers reading feature added in #173, and follows the exact same load_* convention (a private load_footers method called from initialize).

Credit

The footer-reading capability is based on the original implementation by @Jawad79Ahmad in #153. They are credited as a co-author on the commit, and should be credited in the release notes when this ships.

Scope

Reading only — consistent with the headers feature. Write-back (persisting edited footers on save/stream) is intentionally out of scope.

Known limitations

  • footers exposes mutable Nokogiri documents, but update does not write footers back. Editing a footer and saving will not persist the change (read-only).

Tests

  • Reuses the existing spec/fixtures/multi_doc.docx fixture, which already contains word/footer1.xml ("Hello from the footer."), so no new fixture is needed.
  • Adds a read footers spec.
  • Full suite green locally (140 examples, 0 failures).

🤖 Generated with Claude Code

Adds a Docx::Document#footers accessor that exposes word/footer*.xml as a
Hash keyed by footer file name, mirroring the headers reading feature (#173).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Jawad Ahmad <Jawad79Ahmad@users.noreply.github.com>
@satoryu satoryu force-pushed the add-footer-extraction branch from f833512 to ee136a9 Compare May 31, 2026 10:46
@satoryu satoryu changed the title Add ability to read document footers Add ability to read document footers (original work by @Jawad79Ahmad in #153) May 31, 2026
@satoryu satoryu merged commit 3d5cd6e into master May 31, 2026
5 checks passed
@satoryu satoryu deleted the add-footer-extraction branch May 31, 2026 10:52
pull Bot pushed a commit to NeatNerdPrime/docx that referenced this pull request May 31, 2026
Extends Document#update to write modified headers and footers back into the
archive on save/stream, keyed by their original file name (so multiple and
non-sequential header/footer files round-trip correctly). Builds on the
header/footer reading support (ruby-docx#173, ruby-docx#174).

Based on the original read/write implementation by @aashish in ruby-docx#42.

Co-authored-by: aashish <aashish@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant