From: Günter Milde Date: Tue, 30 Apr 2019 09:27:35 +0000 (+0200) Subject: Fix conversion/reversion of parenthese order in Hebrew text. X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=78535407f27cc4e69a66b3149ad20c26c4d92741;p=features.git Fix conversion/reversion of parenthese order in Hebrew text. The algorithm in [c9be8bff74b233/lyxgit] did not account for layout nesting. As a result, some parentheses were swapped in English text parts (e.g. around "(for Linux)" in he/Intro.lyx). --- diff --git a/lib/lyx2lyx/lyx_2_4.py b/lib/lyx2lyx/lyx_2_4.py index 024a5381dd..fa61754f80 100644 --- a/lib/lyx2lyx/lyx_2_4.py +++ b/lib/lyx2lyx/lyx_2_4.py @@ -1435,14 +1435,23 @@ def revert_lformatinfo(document): def convert_hebrew_parentheses(document): - " Don't reverse parentheses in Hebrew text" - current_language = document.language + """ Swap opening/closing parentheses in Hebrew text. + + Up to LyX 2.4, ")" was used as opening parenthesis and + "(" as closing parenthesis for Hebrew in the LyX source. + """ + + print("convert hebrew parentheses") + current_languages = [document.language] for i, line in enumerate(document.body): if line.startswith('\\lang '): - current_language = line[len('\\lang '):] + current_languages[-1] = line.lstrip('\\lang ') + elif line.startswith('\\begin_layout'): + current_languages.append(current_languages[-1]) + print (line, current_languages[-1]) elif line.startswith('\\end_layout'): - current_language = document.language - elif current_language == 'hebrew' and not line.startswith('\\'): + current_languages.pop() + elif current_languages[-1] == 'hebrew' and not line.startswith('\\'): document.body[i] = line.replace('(','\x00').replace(')','(').replace('\x00',')')