Rename ref prefix "sub:" to "subsec:"

This solves a macro conflict between subfloat's \subref and our own
\subref definition (bug #7550)

File format change.
This commit is contained in:
Juergen Spitzmueller 2015-05-24 13:50:21 +02:00
parent 5f6dee3355
commit dbe0096c12
10 changed files with 116 additions and 12 deletions

View 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.

View File

@ -12,6 +12,12 @@
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:

View 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"

View File

@ -22,11 +22,11 @@ IfStyle Section
End
IfStyle Subsection
RefPrefix sub
RefPrefix subsec
End
IfStyle Subsubsection
RefPrefix sub
RefPrefix subsec
End
IfStyle Paragraph

View 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

View 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))
]
####################################################################

View 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]],

View 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"

View 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 };
/**

View 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