Preserve Biber comments within entries#585
Draft
claell wants to merge 1 commit into
Draft
Conversation
* Keep percent-comment lines out of active bibliography fields. * Retain comment content and field-boundary positions during canonical writes. * Preserve comments across edits, CRLF input, and entry copying.
This was referenced Jul 16, 2026
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
Closes #372.
Default behavior
This is implemented in the structural parser rather than as opt-in middleware. A middleware cannot recover a comment that has already caused field parsing to fail or absorb subsequent syntax. The parser therefore recognizes a line whose first non-whitespace character is
%inside an entry and retains it inEntry.comments; it does not expose the text as an active field.The canonical writer preserves content and relative field boundaries, not byte-identical whitespace. Callers may inspect or edit the explicit
EntryCommentobjects. No dialect flag is required merely to avoid losing Biber input.Validation
tests/test_entrypoint.py.Review note
This adds public model state to
Entryand changes splitter marks, so careful API and parser review is requested. The branch includes the same small_skip_marks_beforeiterator helper independently needed by PR #571; whichever PR merges second should remove the duplicate during rebase.AI assistance
This pull request was prepared with ChatGPT Codex using GPT-5.6 Sol with high reasoning effort. Codex assisted with architecture analysis, dependency removal, edge-case testing, and validation. Automated validation is not a substitute for maintainer review.