From f27ea2457dcfa5212f722be04c461e5d109e4fea Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Tue, 13 Jul 2010 14:02:57 +0000 Subject: [PATCH] These didn't get committed with r34884 because I forgot to "svn resolved" them. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34888 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/lyx2lyx/lyx_2_0.py | 40 +++++++++++++++++++++++++++++++++++++++- src/Buffer.cpp | 2 +- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/lib/lyx2lyx/lyx_2_0.py b/lib/lyx2lyx/lyx_2_0.py index 14ffa2ea1f..298ec48014 100644 --- a/lib/lyx2lyx/lyx_2_0.py +++ b/lib/lyx2lyx/lyx_2_0.py @@ -1943,6 +1943,42 @@ def revert_IEEEtran(document): del document.body[i:j + 1] +def revert_nameref(document): + " Convert namerefs to regular references " + # We cannot really revert these properly, so we will + # revert them to commands we understand. + cmds = [["Nameref", "vref"], ["nameref", "ref"]] + for cmd in cmds: + i = 0 + oldcmd = "LatexCommand " + cmd[0] + newcmd = "LatexCommand " + cmd[1] + while 1: + i = find_token(document.body, oldcmd, i) + if i == -1: + break + # Make sure it is actually in an inset! + # We could just check document.lines[i-1], but that relies + # upon something that might easily change. + # We'll look back a few lines. + j = i - 10 + if j < 0: + j = 0 + j = find_token(document.body, "\\begin_inset CommandInset ref", j) + if j == -1 or j > i: + i += 1 + continue + k = find_end_of_inset(document.body, i) + if k == -1: + document.warning("Can't find end of inset at line " + j + "!!") + i += 1 + continue + if k < i: + i += 1 + continue + document.body[i] = newcmd + i += 1 + + ## # Conversion hub # @@ -1998,9 +2034,11 @@ convert = [[346, []], [393, [convert_optarg]], [394, []], [395, []] + [396, []] ] -revert = [[394, [revert_DIN_C_pagesizes]], +revert = [[395, [revert_nameref]], + [394, [revert_DIN_C_pagesizes]], [393, [revert_makebox]], [392, [revert_argument]], [391, [revert_beamer_args]], diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 2a0ef17fe4..d71381e009 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -126,7 +126,7 @@ namespace { // Do not remove the comment below, so we get merge conflict in // independent branches. Instead add your own. -int const LYX_FORMAT = 395; // uwestoehr: support for ISO C paper size series +int const LYX_FORMAT = 396; // rgh: nameref typedef map DepClean; typedef map > RefCache; -- 2.39.2