From: Richard Heck Date: Fri, 5 Nov 2010 15:18:47 +0000 (+0000) Subject: Rename and restructure get_containing_inset. X-Git-Tag: 2.0.0~1999 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=d13394a73bc2b6a0f63666d208d18c00bf972c25;p=features.git Rename and restructure get_containing_inset. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36117 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/lib/lyx2lyx/lyx_2_0.py b/lib/lyx2lyx/lyx_2_0.py index 9ebc31e548..ff3dc8edea 100644 --- a/lib/lyx2lyx/lyx_2_0.py +++ b/lib/lyx2lyx/lyx_2_0.py @@ -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" diff --git a/lib/lyx2lyx/parser_tools.py b/lib/lyx2lyx/parser_tools.py index 19e5054294..e7cee56ba4 100644 --- a/lib/lyx2lyx/parser_tools.py +++ b/lib/lyx2lyx/parser_tools.py @@ -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: