from parser_tools import find_token, find_end_of, find_tokens, \
find_end_of_inset, find_end_of_layout, find_token_backwards, \
- get_containing_inset, get_value, get_quoted_value
+ is_in_inset, get_value, get_quoted_value
from lyx2lyx_tools import add_to_preamble, insert_to_preamble, \
put_cmd_in_ert, lyx2latex, latex_length, revert_flex_inset, \
i += 1
# Make sure it is actually in an inset!
# A normal line could begin with "LatexCommand nameref"!
- stins, endins = get_containing_inset(document.body, cmdloc, \
+ val = is_in_inset(document.body, cmdloc, \
"\\begin_inset CommandInset ref")
- if stins == -1:
- continue
+ if not val:
+ continue
+ stins, endins = val
# ok, so it is in an InsetRef
refline = find_token(document.body, "reference", stins, endins)
i += 1
# Make sure it is actually in an inset!
- stins, endins = get_containing_inset(document.body, \
- cmdloc, "\\begin_inset CommandInset ref")
- if stins == -1:
+ val = is_in_inset(document.body, cmdloc, \
+ "\\begin_inset CommandInset ref")
+ if not val:
continue
document.body[cmdloc] = "LatexCommand nameref"
# checks if line i is in the given inset
# if so, returns starting and ending lines
-# otherwise, returns (-1, -1)
+# otherwise, returns False
# Example:
-# get_containing_inset(document.body, i, "\\begin_inset Tabular")
-# returns (-1, -1) unless i is within a table.
-def get_containing_inset(lines, i, inset):
+# is_in_inset(document.body, i, "\\begin_inset Tabular")
+# returns False unless i is within a table.
+def is_in_inset(lines, i, inset):
defval = (-1, -1)
stins = find_token_backwards(lines, inset, i)
if stins == -1: