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
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
# 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
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',')')