Skip to content

Commit

Permalink
added option to parse_file
Browse files Browse the repository at this point in the history
  • Loading branch information
himcraft committed Aug 31, 2023
1 parent 8cf7dc6 commit 06b30ec
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion bibtexparser/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,20 @@ def parse_file(
path: str,
parse_stack: Optional[Iterable[Middleware]] = None,
append_middleware: Optional[Iterable[Middleware]] = None,
encoding: str = "UTF-8",
) -> Library:
"""Parse a BibTeX file
Args:
path (str): Path to BibTeX file
parse_stack (Optional[Iterable[Middleware]], optional): List of middleware to apply to the database after splitting. If None (default), a default stack will be used providing simple standard functionality will be used.
append_middleware (Optional[Iterable[Middleware]], optional): List of middleware to append to the default stack (ignored if a not-None parse_stack is passed).
encoding: Encoding of the .bib file. Default encoding is "UTF-8".
Returns:
Library: Parsed BibTeX library
"""
with open(path) as f:
with open(path,encoding=encoding) as f:
bibtex_str = f.read()
return parse_string(
bibtex_str, parse_stack=parse_stack, append_middleware=append_middleware
Expand Down

0 comments on commit 06b30ec

Please sign in to comment.