]> git.lyx.org Git - lyx.git/blobdiff - lib/lyx2lyx/lyx2lyx_tools.py
Fixed remaining glitches in tcolorbox reversion routines
[lyx.git] / lib / lyx2lyx / lyx2lyx_tools.py
index 51412e5b31378aed4d27438b93db03c52dfdeca8..f8d30cd4706d74c27ff6ecc3d8b7c467981de0ca 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
@@ -468,7 +465,7 @@ def revert_font_attrs(lines, name, LaTeXname):
   while True:
     i = find_token(lines, name + ' on', i)
     if i == -1:
-      return changed
+      break
     j = find_token(lines, name + ' default', i)
     k = find_token(lines, name + ' on', i + 1)
     # if there is no default set, the style ends with the layout
@@ -482,6 +479,16 @@ def revert_font_attrs(lines, name, LaTeXname):
     changed = True
     i += 1
 
+  # now delete all remaining lines that manipulate this attribute
+  i = 0
+  while True:
+    i = find_token(lines, name, i)
+    if i == -1:
+      break
+    del lines[i]
+
+  return changed
+
 
 def revert_layout_command(lines, name, LaTeXname):
   " Reverts a command from a layout to TeX code "
@@ -607,15 +614,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