#include "LaTeXFeatures.h"
#include "LyX.h"
#include "OutputParams.h"
#include "output_xhtml.h"
#include "ParIterator.h"
#include "sgml.h"
#include "LaTeXFeatures.h"
#include "LyX.h"
#include "OutputParams.h"
#include "output_xhtml.h"
#include "ParIterator.h"
#include "sgml.h"
param_info_.add("name", ParamInfo::LATEX_OPTIONAL);
param_info_.add("reference", ParamInfo::LATEX_REQUIRED,
ParamInfo::HANDLING_ESCAPE);
param_info_.add("name", ParamInfo::LATEX_OPTIONAL);
param_info_.add("reference", ParamInfo::LATEX_REQUIRED,
ParamInfo::HANDLING_ESCAPE);
+ param_info_.add("plural", ParamInfo::LYX_INTERNAL);
+ param_info_.add("caps", ParamInfo::LYX_INTERNAL);
+ param_info_.add("noprefix", ParamInfo::LYX_INTERNAL);
// the ref argument is the label name we are referencing.
// we expect ref to be in the form: pfx:suffix.
//
// the ref argument is the label name we are referencing.
// we expect ref to be in the form: pfx:suffix.
//
// label, thus: \prettyref{pfx:suffix}.
//
docstring InsetRef::getFormattedCmd(docstring const & ref,
// label, thus: \prettyref{pfx:suffix}.
//
docstring InsetRef::getFormattedCmd(docstring const & ref,
{
static docstring const defcmd = from_ascii("\\ref");
static docstring const prtcmd = from_ascii("\\prettyref");
{
static docstring const defcmd = from_ascii("\\ref");
static docstring const prtcmd = from_ascii("\\prettyref");
- docstring const fcmd = getFormattedCmd(data, label, prefix);
- os << fcmd << '{' << label << '}';
+ docstring const fcmd =
+ getFormattedCmd(data, label, prefix, getParam("caps"));
+ os << fcmd;
+ if (buffer().params().use_refstyle && getParam("plural") == "true")
+ os << "[s]";
+ os << '{' << label << '}';
+ }
+ else if (cmd == "labelonly") {
+ docstring const & ref = getParam("reference");
+ if (getParam("noprefix") != "true")
+ os << ref;
+ else {
+ docstring prefix;
+ docstring suffix = split(ref, prefix, ':');
+ if (suffix.empty()) {
+ LYXERR0("Label `" << ref << "' contains no `:' separator.");
+ os << ref;
+ } else {
+ os << suffix;
+ }
+ }
// normally, would be "ref on page #", but we have no pages
display_string = value;
else if (cmd == "pageref" || cmd == "vpageref")
// normally, would be "ref on page #", but we have no pages
display_string = value;
else if (cmd == "pageref" || cmd == "vpageref")
- // normally would be "on page #", but we have no pages
- display_string = _("elsewhere");
+ // normally would be "on page #", but we have no pages.
+ display_string = translateIfPossible(from_ascii("elsewhere"),
+ op.local_font->language()->lang());
else if (cmd == "nameref")
// FIXME We don't really have the ability to handle these
// properly in XHTML output yet (bug #8599).
// It might not be that hard to do. We have the InsetLabel,
// and we can presumably find its paragraph using the TOC.
else if (cmd == "nameref")
// FIXME We don't really have the ability to handle these
// properly in XHTML output yet (bug #8599).
// It might not be that hard to do. We have the InsetLabel,
// and we can presumably find its paragraph using the TOC.
// FIXME What we'd really like to do is to be able to output some
// appropriate sort of text here. But to do that, we need to associate
// some sort of counter with the label, and we don't have that yet.
// FIXME What we'd really like to do is to be able to output some
// appropriate sort of text here. But to do that, we need to associate
// some sort of counter with the label, and we don't have that yet.
- string const attr = "href=\"#" + html::cleanAttr(to_utf8(ref)) + "\"";
- xs << html::StartTag("a", attr);
+ docstring const attr = "href=\"#" + html::cleanAttr(ref) + '"';
+ xs << html::StartTag("a", to_utf8(attr));
{
// There's no need for details in the TOC, and a long label
// will just get in the way.
{
// There's no need for details in the TOC, and a long label
// will just get in the way.
// It seems that this reference does not point to any valid label.
screen_label_ = _("BROKEN: ") + screen_label_;
// It seems that this reference does not point to any valid label.
screen_label_ = _("BROKEN: ") + screen_label_;
- Toc & toc = buffer().tocBackend().toc("label");
- toc.push_back(TocItem(cpit, 0, screen_label_, output_active));
+ shared_ptr<Toc> toc = buffer().tocBackend().toc("label");
+ toc->push_back(TocItem(cpit, 0, screen_label_, output_active));
- string const fcmd = to_utf8(getFormattedCmd(data, label, prefix));
+ docstring const fcmd =
+ getFormattedCmd(data, label, prefix, getParam("caps"));
- string lcmd = "\\AtBeginDocument{\\providecommand" +
- fcmd + "[1]{\\ref{" + to_utf8(prefix) + ":#1}}}";
+ docstring lcmd = "\\AtBeginDocument{\\providecommand" +
+ fcmd + "[1]{\\ref{" + prefix + ":#1}}}";
}
} else if (cmd == "eqref" && !buffer().params().use_refstyle)
// with refstyle, we simply output "(\ref{label})"
}
} else if (cmd == "eqref" && !buffer().params().use_refstyle)
// with refstyle, we simply output "(\ref{label})"
{ "ref", N_("Standard"), N_("Ref: ")},
{ "eqref", N_("Equation"), N_("EqRef: ")},
{ "pageref", N_("Page Number"), N_("Page: ")},
{ "vpageref", N_("Textual Page Number"), N_("TextPage: ")},
{ "vref", N_("Standard+Textual Page"), N_("Ref+Text: ")},
{ "formatted", N_("Formatted"), N_("Format: ")},
{ "ref", N_("Standard"), N_("Ref: ")},
{ "eqref", N_("Equation"), N_("EqRef: ")},
{ "pageref", N_("Page Number"), N_("Page: ")},
{ "vpageref", N_("Textual Page Number"), N_("TextPage: ")},
{ "vref", N_("Standard+Textual Page"), N_("Ref+Text: ")},
{ "formatted", N_("Formatted"), N_("Format: ")},
- { "nameref", N_("Reference to Name"), N_("NameRef:")},
+ { "nameref", N_("Reference to Name"), N_("NameRef: ")},
+ { "labelonly", N_("Label Only"), N_("Label: ")},