]> git.lyx.org Git - features.git/commitdiff
Speed up parenthesis conversion routine for Hebrew. Patch from Guy.
authorRichard Kimberly Heck <rikiheck@lyx.org>
Sat, 3 Nov 2018 13:58:32 +0000 (09:58 -0400)
committerRichard Kimberly Heck <rikiheck@lyx.org>
Sat, 3 Nov 2018 13:58:32 +0000 (09:58 -0400)
lib/lyx2lyx/lyx2lyx_tools.py
lib/lyx2lyx/lyx_2_4.py

index 51412e5b31378aed4d27438b93db03c52dfdeca8..73f7d78c10cfcdb76e877c40e4ebabf78c45eeb9 100644 (file)
@@ -83,9 +83,6 @@ insert_document_option(document, option):
 
 remove_document_option(document, option):
   Remove _option_ as a document option.
-
-get_language_for_line(document, i):
-  Return the language setting for line number i.
 '''
 
 import re
@@ -607,15 +604,3 @@ def is_document_option(document, option):
         return False
 
     return True
-
-
-def get_language_for_line(document, i):
-    " Return the language for line number i"
-    layout = get_containing_layout(document.body, i)
-    if not layout:
-        return document.language
-    start_of_par = layout[3]
-    for line in document.body[i:start_of_par:-1]:
-        if line.startswith('\\lang '):
-            return line[len('\\lang '):]
-    return document.language
index b6b626c31696497eb028647a1fede0aa9ade0123..1a0651473945b05077341423324e085cb6943b10 100644 (file)
@@ -36,7 +36,7 @@ from parser_tools import (count_pars_in_inset, find_end_of_inset, find_end_of_la
 #    is_in_inset, set_bool_value
 #    find_tokens, find_token_exact, check_token
 
-from lyx2lyx_tools import (put_cmd_in_ert, add_to_preamble, get_language_for_line)
+from lyx2lyx_tools import (put_cmd_in_ert, add_to_preamble)
 #  revert_font_attrs, insert_to_preamble, latex_length
 #  get_ert, lyx2latex, lyx2verbatim, length_in_bp, convert_info_insets
 #  revert_flex_inset, hex2ratio, str2bool
@@ -1383,11 +1383,13 @@ def revert_lformatinfo(document):
 
 def convert_hebrew_parentheses(document):
     " Don't reverse parentheses in Hebrew text"
+    current_language = document.language
     for i, line in enumerate(document.body):
-        if line.startswith('\\\\'):
-            # not a text line, skip
-            continue
-        if get_language_for_line(document, i) == 'hebrew':
+        if line.startswith('\\lang '):
+            current_language = line[len('\\lang '):]
+        elif line.startswith('\\end_layout'):
+            current_language = document.language
+        if current_language == 'hebrew' and not line.startswith('\\'):
             document.body[i] = line.replace('(','\x00').replace(')','(').replace('\x00',')')