馃悰 Apply parse stack only to new blocks in parse_string(library=...) - #603
Merged
Merged
Conversation
MiWeiss
force-pushed
the
fix/parse-string-existing-library
branch
3 times, most recently
from
September 2, 2026 20:00
0be036e to
e42a2c1
Compare
Parsing into an existing library re-ran the full parse stack over the blocks already contained in that library. As the parse-stack middlewares are not idempotent, previously parsed entries and strings were corrupted: RemoveEnclosingMiddleware stripped them a second time and stamped a `no-enclosing` demand on the already-stripped values (so the library no longer round-tripped to valid bibtex), and ResolveStringReferencesMiddleware warned about a wrong middleware order. The splitter now fills a fresh library, the parse stack is applied to that one only, and the resulting blocks are merged into the passed library (with `fail_on_duplicate_key=False`, so cross-call duplicates still become DuplicateBlockKeyBlock instances). To keep string references in the new content resolvable against @string blocks defined by earlier calls, tagged deep copies of those strings are seeded into the fresh library and dropped again before merging. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
MiWeiss
force-pushed
the
fix/parse-string-existing-library
branch
from
September 2, 2026 20:03
e42a2c1 to
64c208c
Compare
Collaborator
Author
|
lgtm |
MiWeiss
added a commit
that referenced
this pull request
Sep 2, 2026
Since #603, `parse_string` builds a fresh `Library` and merges the result instead of handing the caller's library to the splitter, so nothing in the package (or the tests, docs or README) passes `library=` to `Splitter.split()` any more. Removing it rather than keeping an unused public parameter, while 2.0.0 is still unreleased (2.0.0b9). `split()` now always returns a new `Library`; the `Splitter` class and `split()` itself stay public. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
MiWeiss
added a commit
that referenced
this pull request
Sep 2, 2026
Since #603, `parse_string` builds a fresh `Library` and merges the result instead of handing the caller's library to the splitter, so nothing in the package (or the tests, docs or README) passes `library=` to `Splitter.split()` any more. Removing it rather than keeping an unused public parameter, while 2.0.0 is still unreleased (2.0.0b9). `split()` now always returns a new `Library`; the `Splitter` class and `split()` itself stay public. Co-authored-by: Claude Opus 5 <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.
parse_string(library=existing)runs the parse stack over the merged library, re-transforming blocks an earlier call already transformed. The middlewares are not idempotent.Before: a spurious "RemoveEnclosingMiddleware must not run before..." warning, and output containing
title = Hello Worldand@string{me = My Name}. Unenclosed, invalid, does not round-trip.Fix: split into a fresh library, run the stack there, merge with
fail_on_duplicate_key=False.Cross-call string resolution works today, so it is kept: tagged deep copies of the caller's
@stringblocks are seeded into the fresh library and filtered out before the merge. Originals untouched.Worth a decision:
Splitter.split(library=...)is now unused inside the package. Left public and untouched.Tests: 12 cases. The parameter had no coverage at all before. Suite 2588 passed, from 2576.
馃 Generated with Claude Code