mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-21 23:09:40 +00:00
Label only command for reference dialog.
This commit is contained in:
parent
9a9288d67d
commit
c513c26e62
@ -25,14 +25,11 @@ import sys, os
|
||||
|
||||
# Uncomment only what you need to import, please.
|
||||
|
||||
from parser_tools import find_end_of, find_token_backwards, find_end_of_layout#,
|
||||
# find_token, find_tokens, \
|
||||
# find_token_exact, find_end_of_inset, \
|
||||
# is_in_inset, get_value, get_quoted_value, \
|
||||
# del_token, check_token, get_option_value, get_bool_value
|
||||
|
||||
from parser_tools import find_token, find_end_of_inset, get_value, \
|
||||
get_bool_value, get_containing_layout
|
||||
from parser_tools import find_end_of, find_token_backwards, find_end_of_layout, \
|
||||
find_token, find_end_of_inset, get_value, get_bool_value, \
|
||||
get_containing_layout
|
||||
# find_tokens, find_token_exact, is_in_inset, get_quoted_value, \
|
||||
# del_token, check_token, get_option_value
|
||||
|
||||
from lyx2lyx_tools import add_to_preamble, put_cmd_in_ert
|
||||
# get_ert, lyx2latex, \
|
||||
@ -40,8 +37,6 @@ from lyx2lyx_tools import add_to_preamble, put_cmd_in_ert
|
||||
# insert_to_preamble, latex_length, revert_flex_inset, \
|
||||
# revert_font_attrs, hex2ratio, str2bool
|
||||
|
||||
from lyx2lyx_tools import add_to_preamble, put_cmd_in_ert
|
||||
|
||||
####################################################################
|
||||
# Private helper functions
|
||||
|
||||
@ -1065,6 +1060,39 @@ def revert_cochinealmath(document):
|
||||
document.header[i] = document.header[i].replace("cochineal-ntxm", "auto")
|
||||
|
||||
|
||||
def revert_labelonly(document):
|
||||
" Revert labelonly tag for InsetRef "
|
||||
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("Can't find end of reference inset at line %d!!" %(i))
|
||||
i += 1
|
||||
continue
|
||||
k = find_token(document.body, "LatexCommand labelonly", i, j)
|
||||
if k == -1:
|
||||
i = j
|
||||
continue
|
||||
m = find_token(document.body, "reference", i, j)
|
||||
if m == -1:
|
||||
document.warning("Can't find label for reference at line %d!" %(i))
|
||||
i = j + 1
|
||||
continue
|
||||
lm = re.match(r'reference\s+"([^"]+)"', document.body[m])
|
||||
if not lm:
|
||||
document.warning("Can't find label for reference at line %d!" %(i))
|
||||
i = j + 1
|
||||
continue
|
||||
label = lm.group(1)
|
||||
document.body[i:j+1] = put_cmd_in_ert([label])
|
||||
i = j + 1
|
||||
continue
|
||||
|
||||
|
||||
|
||||
##
|
||||
# Conversion hub
|
||||
#
|
||||
@ -1086,10 +1114,12 @@ convert = [
|
||||
[521, [convert_frenchquotes]],
|
||||
[522, []],
|
||||
[523, []],
|
||||
[524, []]
|
||||
[524, []],
|
||||
[525, []]
|
||||
]
|
||||
|
||||
revert = [
|
||||
[524, [revert_labelonly]],
|
||||
[523, [revert_crimson, revert_cochinealmath]],
|
||||
[522, [revert_cjkquotes]],
|
||||
[521, [revert_dynamicquotes]],
|
||||
|
@ -258,6 +258,11 @@
|
||||
<string>Textual reference</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Label only</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -57,7 +57,8 @@ bool InsetRef::isCompatibleCommand(string const & s) {
|
||||
|| s == "vpageref"
|
||||
|| s == "formatted"
|
||||
|| s == "eqref"
|
||||
|| s == "nameref";
|
||||
|| s == "nameref"
|
||||
|| s == "labelonly";
|
||||
}
|
||||
|
||||
|
||||
@ -160,6 +161,9 @@ void InsetRef::latex(otexstream & os, OutputParams const & rp) const
|
||||
docstring const fcmd = getFormattedCmd(data, label, prefix);
|
||||
os << fcmd << '{' << label << '}';
|
||||
}
|
||||
else if (cmd == "labelonly") {
|
||||
os << getParam("reference");
|
||||
}
|
||||
else {
|
||||
// We don't want to output p_["name"], since that is only used
|
||||
// in docbook. So we construct new params, without it, and use that.
|
||||
@ -356,6 +360,7 @@ InsetRef::type_info const InsetRef::types[] = {
|
||||
{ "vref", N_("Standard+Textual Page"), N_("Ref+Text: ")},
|
||||
{ "formatted", N_("Formatted"), N_("Format: ")},
|
||||
{ "nameref", N_("Reference to Name"), N_("NameRef: ")},
|
||||
{ "labelonly", N_("Label Only"), N_("Label: ")},
|
||||
{ "", "", "" }
|
||||
};
|
||||
|
||||
|
@ -32,7 +32,7 @@ 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 524 // spitz: crimson/cochineal font
|
||||
#define LYX_FORMAT_LYX 525 // rgh: labelonly for references
|
||||
#define LYX_FORMAT_TEX2LYX 524
|
||||
|
||||
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
|
||||
|
Loading…
x
Reference in New Issue
Block a user