]> git.lyx.org Git - features.git/commitdiff
Rename ref prefix "sub:" to "subsec:"
authorJuergen Spitzmueller <spitz@lyx.org>
Sun, 24 May 2015 11:50:21 +0000 (13:50 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Sun, 24 May 2015 11:50:21 +0000 (13:50 +0200)
This solves a macro conflict between subfloat's \subref and our own
\subref definition (bug #7550)

File format change.

development/FORMAT
lib/RELEASE-NOTES
lib/layouts/beamer.layout
lib/layouts/stdrefprefix.inc
lib/layouts/tufte-book.layout
lib/lyx2lyx/LyX.py
lib/lyx2lyx/lyx_2_2.py
src/LaTeXFeatures.cpp
src/tex2lyx/text.cpp
src/version.h

index fb2088b95852c04ce922e79f6a15dc4754f2a0bd..770ceaa40dd47cdb9a3f3c64288d339456316f1c 100644 (file)
@@ -11,6 +11,10 @@ adjustments are made to tex2lyx and bugs are fixed in lyx2lyx.
 
 -----------------------
 
+2015-05-24 Jürgen Spitzmüller <spitz@lyx.org>
+       * Format incremented to 495: Rename sub: refprefix to subsec: in order
+          to prevent clash of \\subref command with subfloat package.
+
 2015-05-24 Uwe Stöhr <uwestoehr@web.de>
        * Format incremented to 494: support more layouts in jss.layout
          No new parameters.
index 0127d9f19233148c9973ca24f2eb5cad9f829e36..8d255bd34bc2e8615cfc7c858cd53d0d81eecf83 100644 (file)
   the GUI (though some menu entries use it) as it is automatically inserted
   when needed. See Section 3.4.6 of the User Guide for details.
 
+* The prefix for subsections in labels and references has been changed from
+  "sub:" to "subsec:" in order to avoid a clash with subfloats (conflicting
+  \subref command, see bug #7550). Files are automatically converted to the new scheme.
+  Please assure that you adapt external refstyle or prettyref definitions and
+  your own layout files.
+
 !!!The following pref variables were added in 2.2:
 
 * \save_origin:
index a56dbd9d28c9839cac9173393ce0b3a69c1d0e76..b8390d354b4cdac0e813429dce4229461c101cf7 100644 (file)
@@ -309,7 +309,7 @@ Style Subsection
   LabelType        Static
   LabelCounter     subsection
   LabelString      "Subsection \arabic{section}.\arabic{subsection}"
-  RefPrefix        sub
+  RefPrefix        subsec
   Argument 1
     LabelString    "Mode"
     MenuString     "Mode Specification|S"
index 7412d953a979ff05d839df572e4cc667d868de27..3efe8194f8d05582decff0b45466141554f515b7 100644 (file)
@@ -22,11 +22,11 @@ IfStyle Section
 End
 
 IfStyle Subsection
-       RefPrefix sub
+       RefPrefix subsec
 End
 
 IfStyle Subsubsection
-       RefPrefix sub
+       RefPrefix subsec
 End
 
 IfStyle Paragraph
index da6c7b105dfb5c638cb29cd22e7a7a1ef1ea2ec3..3a191a49a942a7894a67fc1059b98bf0ddc0efa8 100644 (file)
@@ -122,7 +122,7 @@ Style Subsection
        TopSep                  0.9
        BottomSep               0.5
        ParSep                  0.5
-       RefPrefix               sub
+       RefPrefix               subsec
        Font
          Series                Bold
          Size                  Large
index 15ad32c4f41a5987233c235b49e2a5000eb71798..73818fa827557f1492dcf405823f4b15576b6c1b 100644 (file)
@@ -85,7 +85,7 @@ format_relation = [("0_06",    [200], minor_versions("0.6" , 4)),
                    ("1_6", list(range(277,346)), minor_versions("1.6" , 10)),
                    ("2_0", list(range(346,414)), minor_versions("2.0" , 8)),
                    ("2_1", list(range(414,475)), minor_versions("2.1" , 0)),
-                   ("2_2", list(range(475,495)), minor_versions("2.2" , 0))
+                   ("2_2", list(range(475,496)), minor_versions("2.2" , 0))
                   ]
 
 ####################################################################
index 18f4838581d22ce9dacd870d1626be8486902710..c18d905509baa199e50be316818e73c2b2460e42 100644 (file)
@@ -1424,6 +1424,98 @@ def revert_jss(document):
           k = k + 1
 
 
+def convert_subref(document):
+    " converts sub: ref prefixes to subref: "
+
+    # 1) label insets
+    rx = re.compile(r'^name \"sub:(.+)$')
+    i = 0
+    while True:
+        i = find_token(document.body, "\\begin_inset CommandInset label", i)
+        if i == -1:
+            break
+        j = find_end_of_inset(document.body, i)
+        if j == -1:
+            document.warning("Malformed LyX document: Can't find end of Label inset at line " + str(i))
+            i += 1
+            continue
+
+        for p in range(i, j):
+            m = rx.match(document.body[p])
+            if m:
+                label = m.group(1)
+                document.body[p] = "name \"subsec:" + label
+        i += 1
+
+    # 2) xref insets
+    rx = re.compile(r'^reference \"sub:(.+)$')
+    i = 0
+    while True:
+        i = find_token(document.body, "\\begin_inset CommandInset ref", i)
+        if i == -1:
+            return
+        j = find_end_of_inset(document.body, i)
+        if j == -1:
+            document.warning("Malformed LyX document: Can't find end of Ref inset at line " + str(i))
+            i += 1
+            continue
+
+        for p in range(i, j):
+            m = rx.match(document.body[p])
+            if m:
+                label = m.group(1)
+                document.body[p] = "reference \"subsec:" + label
+                break
+        i += 1
+
+
+
+def revert_subref(document):
+    " reverts subref: ref prefixes to sub: "
+
+    # 1) label insets
+    rx = re.compile(r'^name \"subsec:(.+)$')
+    i = 0
+    while True:
+        i = find_token(document.body, "\\begin_inset CommandInset label", i)
+        if i == -1:
+            break
+        j = find_end_of_inset(document.body, i)
+        if j == -1:
+            document.warning("Malformed LyX document: Can't find end of Label inset at line " + str(i))
+            i += 1
+            continue
+
+        for p in range(i, j):
+            m = rx.match(document.body[p])
+            if m:
+                label = m.group(1)
+                document.body[p] = "name \"sub:" + label
+                break
+        i += 1
+
+    # 2) xref insets
+    rx = re.compile(r'^reference \"subsec:(.+)$')
+    i = 0
+    while True:
+        i = find_token(document.body, "\\begin_inset CommandInset ref", i)
+        if i == -1:
+            return
+        j = find_end_of_inset(document.body, i)
+        if j == -1:
+            document.warning("Malformed LyX document: Can't find end of Ref inset at line " + str(i))
+            i += 1
+            continue
+
+        for p in range(i, j):
+            m = rx.match(document.body[p])
+            if m:
+                label = m.group(1)
+                document.body[p] = "reference \"sub:" + label
+                break
+        i += 1
+
+
 ##
 # Conversion hub
 #
@@ -1452,10 +1544,12 @@ convert = [
            [491, []],
            [492, [convert_colorbox]],
            [493, []],
-           [494, []]
+           [494, []],
+           [495, [convert_subref]]
           ]
 
 revert =  [
+           [494, [revert_subref]],
            [493, [revert_jss]],
            [492, [revert_mathmulticol]],
            [491, [revert_colorbox]],
index 84c492b89615bec0770667344622feb62467011f..5a05ef1e439c9afd91b3840634a46b739b073934 100644 (file)
@@ -249,8 +249,8 @@ static docstring const ogonek_def = from_ascii(
        "\\newcommand{\\ogonek}[1]{\\mathpalette\\doogonek{#1}}\n");
 
 static docstring const lyxref_def = from_ascii(
-               "\\RS@ifundefined{subref}\n"
-               "  {\\def\\RSsubtxt{section~}\\newref{sub}{name = \\RSsubtxt}}\n"
+               "\\RS@ifundefined{subsecref}\n"
+               "  {\\newref{subsec}{name = \\RSsectxt}}\n"
                "  {}\n"
                "\\RS@ifundefined{thmref}\n"
                "  {\\def\\RSthmtxt{theorem~}\\newref{thm}{name = \\RSthmtxt}}\n"
index ed2a3f7d9d52c637348eedcb91ccf0003c51ecca..d510c0010ec45b0e24c40026c9933c686b7fdc9c 100644 (file)
@@ -137,11 +137,11 @@ char const * const known_coded_ref_commands[] = { "ref", "pageref", "vref",
 
 char const * const known_refstyle_commands[] = { "algref", "chapref", "corref",
  "eqref", "enuref", "figref", "fnref", "lemref", "parref", "partref", "propref",
- "secref", "subref", "tabref", "thmref", 0 };
+ "secref", "subsecref", "tabref", "thmref", 0 };
 
 char const * const known_refstyle_prefixes[] = { "alg", "chap", "cor",
  "eq", "enu", "fig", "fn", "lem", "par", "part", "prop",
- "sec", "sub", "tab", "thm", 0 };
+ "sec", "subsec", "tab", "thm", 0 };
 
 
 /**
index 9746f1b693b71ff54f25b3c7e42c7a152dcf2a5c..79ea6cc9017eb3d761547444a3b58dc83a158cbf 100644 (file)
@@ -32,8 +32,8 @@ extern char const * const lyx_version_info;
 
 // Do not remove the comment below, so we get merge conflict in
 // independent branches. Instead add your own.
-#define LYX_FORMAT_LYX 494 // uwestoehr jss layout changes
-#define LYX_FORMAT_TEX2LYX 494
+#define LYX_FORMAT_LYX 495 // spitz: subsection ref prefix change
+#define LYX_FORMAT_TEX2LYX 495
 
 #if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
 #ifndef _MSC_VER