Fix corrupt PDF crash and --global-index field parsing for auto-generated COLLECTION.md#30
Merged
Conversation
…ated COLLECTION.md - Wrap convert_publication() call in try/except so corrupt PDFs log a warning and are skipped rather than aborting the entire run - Update --global-index regexes to match both hand-crafted bold format (**Period**, **Pages**) and auto-generated plain format (Date range, Total pages) so period/pages columns populate correctly for collections built with --write-collection-md Fixes surfaced in ali5ter/electronics-publications-library commit f8f8403. Co-Authored-By: Claude Sonnet 4.6 <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
convert_publication()callsfitz.open(), which raisespymupdf.FileDataErroron corrupt PDFs, aborting the entire run. Wraps the call intry/except Exceptionso the offending PDF is skipped with a warning and the run continues.--global-indexmisses auto-generated fields: Thewrite_global_index()parser matched only the hand-crafted bold format (**Period**,**Pages**) but--write-collection-mdoutputs plain-text labels (Date range,Total pages). Updated the twore.searchregexes to match both formats via alternation, so Period and Pages populate correctly regardless of how COLLECTION.md was authored.Both fixes were surfaced in the downstream instance (ali5ter/electronics-publications-library@f8f8403).
Test plan
convert.pyagainst a directory that includes a corrupt PDF — confirm it logsWARNING: skipping <file>and continues rather than crashingconvert.py --write-collection-mdto generate an auto-format COLLECTION.md, then runconvert.py --global-index collections/— confirm Period and Pages columns are populated in CATALOGUE.md--global-indexagainst a hand-crafted COLLECTION.md with**Period**/**Pages**bold fields — confirm those still populate correctly🤖 Generated with Claude Code