Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ We are always looking for people to improve the library. Contributions include,

### Some guidelines

1. Be nice! Were all doing this in our free time; no one is obligated to do anything.
1. Be nice! We're all doing this in our free time; no one is obligated to do anything.
2. Add sufficient tests to your PRs.
3. Document your code.
4. Don't hesitate to ask questions.
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# python-bibtexparser v2

Welcome to python-bibtexparser, a parser for `.bib` files with a long history and wide adaption.
Welcome to python-bibtexparser, a parser for `.bib` files with a long history and wide adoption.

Bibtexparser is available in two versions: V1 and V2. For new projects, we recommend using v2 which, in the long run, will provide an overall more robust and faster experience. **For now, however, note that v2 is an early beta, and does not contain all features of v1**. Install v2 using pip:

Expand Down Expand Up @@ -61,7 +61,7 @@ bib_database = bibtexparser.parse_string(bibtex_string,

# Let's transform it back to a bibtex_string.
new_bibtex_string = bibtexparser.write_string(bib_database,
# Revert aboves transfomration
# Revert above transformation
prepend_middleware=[MergeNameParts(), MergeCoAuthors()]
)
```
Expand All @@ -76,14 +76,14 @@ Consult the documentation for a list of available middleware, parsing options an
The architecture consists of the following components:

#### Library
Reflects the contents of a parsed bibtex files, including all comments, entries, strings, preamples and their metadata (e.g. order).
Reflects the contents of a parsed bibtex files, including all comments, entries, strings, preambles and their metadata (e.g. order).

#### A Splitter
Splits a bibtex string into basic blocks (Entry, String, Preamble, ...), with correspondingly split content (e.g. fields on Entry, key-value on String, ...).
The splitter aims to be forgiving when facing invalid bibtex: A line starting with a block definition (``@....``) ends the previous block, even if not yet every bracket is closed, failing the parsing of the previous block. Correspondingly, one block type is "ParsingFailedBlock".

#### Middleware
Middleware layers transform a library and its blocks, for example by decoding latex special characters, interpolating string references, resoling crossreferences or re-ordering blocks. Thus, the choice of middleware allows to customize parsing and writing to ones specific usecase. Note: Middlewares, by default, no not mutate their input, but return a modified copy.
Middleware layers transform a library and its blocks, for example by decoding latex special characters, interpolating string references, resolving crossreferences or re-ordering blocks. Thus, the choice of middleware allows to customize parsing and writing to ones specific usecase. Note: Middlewares, by default, do not mutate their input, but return a modified copy.

#### Writer
Writes the content of a bibtex library to a ``.bib`` file. Optional formatting parameters can be passed using a corresponding dedicated data structure.
Expand Down
2 changes: 1 addition & 1 deletion bibtexparser/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def write_string(
:param unparse_stack: List of middleware to apply to the database before writing.
If None, a default stack will be used.
:param prepend_middleware: List of middleware to prepend to the default stack.
Only applicable if `parse_stack` is None.
Only applicable if `unparse_stack` is None.
:param bibtex_format: Customized BibTeX format to use (optional).
"""
middleware: Middleware
Expand Down
6 changes: 3 additions & 3 deletions bibtexparser/middlewares/latex_encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,9 @@ def __init__(

if decoder is not None and (keep_braced_groups is not None or keep_math_mode is not None):
raise ValueError(
"Cannot specify both encoder and one of "
"`keep_braced_groups` or `keep_braced_groups`."
"If you want to use a custom encoder, "
"Cannot specify both decoder and one of "
"`keep_braced_groups` or `keep_math_mode`."
"If you want to use a custom decoder, "
"you have to specify it completely."
)

Expand Down
2 changes: 1 addition & 1 deletion bibtexparser/middlewares/names.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def metadata_key(cls) -> str:
return "merge_name_parts"

def _transform_field_value(self, name) -> List[str]:
if not isinstance(name, list) and all(isinstance(n, NameParts) for n in name):
if not (isinstance(name, list) and all(isinstance(n, NameParts) for n in name)):
raise ValueError(f"Expected a list of NameParts, got {name}. ")

if self.style == "last":
Expand Down
2 changes: 1 addition & 1 deletion bibtexparser/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


class Block(abc.ABC):
"""A abstract superclass of all top-level building blocks of a bibtex file.
"""An abstract superclass of all top-level building blocks of a bibtex file.

E.g. a ``@string`` block, a ``@preamble`` block, an ``@entry`` block, a comment, etc.
"""
Expand Down
2 changes: 1 addition & 1 deletion bibtexparser/splitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def split(self, library: Optional[Library] = None) -> Library:
logger.error(e.message)
raise e
except Exception as e:
# For unknown exeptions, we want to fail hard and get the info in our issue tracker.
# For unknown exceptions, we want to fail hard and get the info in our issue tracker.
logger.error(
f"Unexpected exception while parsing `{m_val}` block (line {start_line})"
"Please report this bug."
Expand Down
4 changes: 2 additions & 2 deletions docs/source/biber.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Biber & Biblatex
================


Due to its simpel and high-level nature, this library should not only support BibTeX, but also be able to part biblatex and biber files
Due to its simple and high-level nature, this library should not only support BibTeX, but also be able to parse biblatex and biber files
with ease, as they all share the same general syntax.

That said, we did not explicitely check against all of biber and biblatex features. Should you detect anything which is not supported,
That said, we did not explicitly check against all of biber and biblatex features. Should you detect anything which is not supported,
please open an issue or send a pull request.
2 changes: 1 addition & 1 deletion docs/source/customize.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ Names

* :mod:`bibtexparser.middlewares.SeparateCoAuthors`
* :mod:`bibtexparser.middlewares.MergeCoAuthors`
* :mod:`bibtexparser.middlewares.SplitNameParts` (requires SeperateCoAuthors to be applied first)
* :mod:`bibtexparser.middlewares.SplitNameParts` (requires SeparateCoAuthors to be applied first)
* :mod:`bibtexparser.middlewares.MergeNameParts`

.. _middleware_sorting:
Expand Down
1 change: 1 addition & 0 deletions docs/source/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Installation
Requirements
------------


Bibtexparser's only requirement is a python interpreter which is not yet EOL (currently >= 3.9).

As of version 2.0.0, bibtexparser is a pure-python project (no direct bindings to C libraries).
Expand Down
6 changes: 3 additions & 3 deletions docs/source/migrate.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Status of v2

The v2 branch is well tested and reasonably stable, but it is not yet widely adopted - as an early adopter,
you may encounter some bugs. If you do, please report them on the issue tracker.
Also, note that some interfaces may change sightly before we release v2.0.0 as stable.
Also, note that some interfaces may change slightly before we release v2.0.0 as stable.

Some customizations from v1 are not implemented in v2, as we doubt they are widely used. If you need one of
these features, please let us know on the issue tracker.
Expand Down Expand Up @@ -51,7 +51,7 @@ As such, it makes reduced use of the new features of v2 and makes use of backwar
Changing the entrypoint with default settings
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To make sure that users dont "migrate by accident" to bibtex v2, we changed the entrypoint of the package:
To make sure that users don't "migrate by accident" to bibtex v2, we changed the entrypoint of the package:

.. code-block:: python

Expand Down Expand Up @@ -102,5 +102,5 @@ but for them, the migration is straight forward and we will not go into detail h
Writing a bibtex file (possibly with customizations)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The way to write a bibtex file has changed fundamentally in v2, and is now handeled in a fashion very similar to the parsing.
The way to write a bibtex file has changed fundamentally in v2, and is now handled in a fashion very similar to the parsing.
See the :ref:`writing quickstart <writing_quickstart>` and :ref:`writing formatting <writing_formatting>` for more information.
2 changes: 1 addition & 1 deletion docs/source/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Prerequisite: Vocabulary
In an entry, you can find

* an **entry type** like ``article``, ``book``, etc.
* and **entry key**, e.g. ``Cesar2013`` in ``@article{Cesar2013, ...}``.
* an **entry key**, e.g. ``Cesar2013`` in ``@article{Cesar2013, ...}``.
* and **fields**, which are the key-value pairs in the entry, e.g. ``author = {Jean César}``.
* each field has a **field key** and a **field value**.

Expand Down
Loading