Do not reverse parentheses in pass thru insets (#12966)

This commit is contained in:
Juergen Spitzmueller 2023-11-08 15:14:37 +01:00
parent bdaad03a45
commit 412d202fc3

View File

@ -1529,6 +1529,8 @@ def convert_hebrew_parentheses(document):
""" """
# print("convert hebrew parentheses") # print("convert hebrew parentheses")
current_languages = [document.language] current_languages = [document.language]
# skip math and pass thru insets
skip_insets = ['Formula', 'ERT', 'listings']
i = 0 i = 0
while i < len(document.body): while i < len(document.body):
line = document.body[i] line = document.body[i]
@ -1539,10 +1541,13 @@ def convert_hebrew_parentheses(document):
# print (line, current_languages[-1]) # print (line, current_languages[-1])
elif line.startswith('\\end_layout'): elif line.startswith('\\end_layout'):
current_languages.pop() current_languages.pop()
elif line.startswith('\\begin_inset Formula'): elif line.startswith('\\begin_inset '):
# In math, parentheses must not be changed tokenend = len('\\begin_inset ')
i = find_end_of_inset(document.body, i) inset = line[tokenend:].strip()
continue if inset in skip_insets:
# In these insets, parentheses must not be changed
i = find_end_of_inset(document.body, i)
continue
elif current_languages[-1] == 'hebrew' and not line.startswith('\\'): elif current_languages[-1] == 'hebrew' and not line.startswith('\\'):
document.body[i] = line.replace('(','\x00').replace(')','(').replace('\x00',')') document.body[i] = line.replace('(','\x00').replace(')','(').replace('\x00',')')
i += 1 i += 1