Fix glitch in revert_biblatex_chicago

This commit is contained in:
Juergen Spitzmueller 2024-07-10 09:50:15 +02:00
parent 18ce7a2e80
commit f96422fc9c

View File

@ -273,20 +273,22 @@ def convert_biblatex_chicago(document):
def revert_biblatex_chicago(document): def revert_biblatex_chicago(document):
"""Revert biblatex-chicago to ERT where necessary""" """Revert biblatex-chicago to ERT where necessary"""
# 1. Get and reset cite engine # 1. Get cite engine
engine = "basic" engine = "basic"
i = find_token(document.header, "\\cite_engine", 0) i = find_token(document.header, "\\cite_engine", 0)
if i == -1: if i == -1:
document.warning("Malformed document! Missing \\cite_engine") document.warning("Malformed document! Missing \\cite_engine")
else: else:
engine = get_value(document.header, "\\cite_engine", i) engine = get_value(document.header, "\\cite_engine", i)
document.header[i] = "\\cite_engine biblatex"
# 2. Do we use biblatex-chicago? # 2. Do we use biblatex-chicago?
if engine != "biblatex-chicago": if engine != "biblatex-chicago":
return return
# 3. Reset cite engine
document.header[i] = "\\cite_engine biblatex"
# 3. Set cite type # 4. Set cite type
cetype = "authoryear" cetype = "authoryear"
i = find_token(document.header, "\\cite_engine_type", 0) i = find_token(document.header, "\\cite_engine_type", 0)
if i == -1: if i == -1:
@ -295,7 +297,7 @@ def revert_biblatex_chicago(document):
cetype = get_value(document.header, "\\cite_engine_type", i) cetype = get_value(document.header, "\\cite_engine_type", i)
document.header[i] = "\\cite_engine_type authoryear" document.header[i] = "\\cite_engine_type authoryear"
# 4. Add authordate option if needed # 5. Add authordate option if needed
if cetype == "authoryear": if cetype == "authoryear":
i = find_token(document.header, "\\biblio_options", 0) i = find_token(document.header, "\\biblio_options", 0)
if i != -1: if i != -1:
@ -309,10 +311,10 @@ def revert_biblatex_chicago(document):
else: else:
document.header[i+1:i+1] = ["\\biblio_options authordate"] document.header[i+1:i+1] = ["\\biblio_options authordate"]
# 5. Set local layout # 6. Set local layout
document.append_local_layout(chicago_local_layout) document.append_local_layout(chicago_local_layout)
# 6. Handle special citation commands # 7. Handle special citation commands
# Specific citation insets used in biblatex that need to be reverted to ERT # Specific citation insets used in biblatex that need to be reverted to ERT
new_citations = { new_citations = {
"atcite": "atcite", "atcite": "atcite",