]> git.lyx.org Git - lyx.git/commitdiff
These didn't get committed with r34884 because I forgot to "svn
authorRichard Heck <rgheck@comcast.net>
Tue, 13 Jul 2010 14:02:57 +0000 (14:02 +0000)
committerRichard Heck <rgheck@comcast.net>
Tue, 13 Jul 2010 14:02:57 +0000 (14:02 +0000)
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
src/Buffer.cpp

index 14ffa2ea1f2f1496a72290915a261d50689e6e31..298ec480146cff3af0eda179615411d2b3e23a26 100644 (file)
@@ -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]],
index 2a0ef17fe49fa96f5d234be69a05adb63be8f593..d71381e009773590e1904accae9431a62e73e3ba 100644 (file)
@@ -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<string, bool> DepClean;
 typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;