Rename and restructure get_containing_inset.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36117 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2010-11-05 15:18:47 +00:00
parent 5fe584cc9c
commit d13394a73b
2 changed files with 12 additions and 11 deletions

View File

@ -25,7 +25,7 @@ import sys, os
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, \
@ -1619,10 +1619,11 @@ def revert_nameref(document):
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)
@ -1655,9 +1656,9 @@ def remove_Nameref(document):
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"

View File

@ -245,11 +245,11 @@ def find_end_of_layout(lines, i):
# 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: