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
14 changes: 12 additions & 2 deletions bibtexparser/middlewares/latex_encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,15 @@ def __init__(

if encoder is not None and (keep_math is not None or enclose_urls is not None):
raise ValueError(
"Cannot specify both encoder and keep_math or enclose_urls."
"Cannot specify both encoder and keep_math or enclose_urls. "
"If you want to use a custom encoder, you have to specify it completely."
)

if encoder is not None and not isinstance(encoder, UnicodeToLatexEncoder):
raise TypeError(
f"encoder must be a UnicodeToLatexEncoder instance, got {type(encoder).__name__}"
)

# Defaults (not specified as defaults in args,
# to make sure we can identify if they were specified)
keep_math = keep_math if keep_math is not None else True
Expand Down Expand Up @@ -167,11 +172,16 @@ 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 decoder and one of "
"`keep_braced_groups` or `keep_math_mode`."
"`keep_braced_groups` or `keep_math_mode`. "
"If you want to use a custom decoder, "
"you have to specify it completely."
)

if decoder is not None and not isinstance(decoder, LatexNodes2Text):
raise TypeError(
f"decoder must be a LatexNodes2Text instance, got {type(decoder).__name__}"
)

# Defaults (not specified as defaults in args,
# to make sure we can identify if they were specified)
keep_braced_groups = keep_braced_groups if keep_braced_groups is not None else False
Expand Down
Loading