Add ability to read document footers (original work by @Jawad79Ahmad in #153)#174
Merged
Conversation
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>
f833512 to
ee136a9
Compare
This was referenced May 31, 2026
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the ability to read document footers (
word/footer*.xml) via a newDocx::Document#footersaccessor. Footers are exposed as aHashkeyed by the footer file name (e.g."footer1"), with each value being a parsedNokogiri::XMLdocument.This is the footer counterpart to the headers reading feature added in #173, and follows the exact same
load_*convention (a privateload_footersmethod called frominitialize).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
footersexposes mutableNokogiridocuments, butupdatedoes not write footers back. Editing a footer and saving will not persist the change (read-only).Tests
spec/fixtures/multi_doc.docxfixture, which already containsword/footer1.xml("Hello from the footer."), so no new fixture is needed.read footersspec.140 examples, 0 failures).🤖 Generated with Claude Code