Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions bibtexparser/splitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,22 +285,17 @@ def _move_to_end_of_entry(self, first_key_start: int) -> tuple[list[Field], int,
end_index=after_field_mark.start(),
)

def split(self, library: Library | None = None) -> Library:
"""Split the bibtex-string into blocks and add them to the library.
def split(self) -> Library:
"""Split the bibtex-string into blocks and return them as a new library.

Args:
library: The library to add the blocks to. If None, a new library is created.
Returns:
The library with the added blocks.
A new library containing the split blocks.
"""
self._markiter = re.finditer(
r"(?<!\\)[\{\}\",=\n]|@[\w]*( |\t)*(?={)", self.bibstr, re.MULTILINE
)

if library is None:
library = Library()
else:
logger.info("Adding blocks to existing library.")
library = Library()

while True:
m = self._next_mark(accept_eof=True)
Expand Down
Loading