namespace {
-
+
// FIXME See the header for the issue.
-string defaultCiteCommand(CiteEngine engine)
+string defaultCiteCommand(CiteEngine engine, CiteEngineType engine_type)
{
string str;
switch (engine) {
case ENGINE_BASIC:
str = "cite";
break;
- case ENGINE_NATBIB_AUTHORYEAR:
- str = "citet";
- break;
- case ENGINE_NATBIB_NUMERICAL:
- str = "citep";
+ case ENGINE_NATBIB:
+ if (engine_type == ENGINE_TYPE_AUTHORYEAR)
+ str = "citet";
+ else
+ str = "citep";
break;
case ENGINE_JURABIB:
str = "cite";
return str;
}
-
-string asValidLatexCommand(string const & input, CiteEngine const engine)
+
+string asValidLatexCommand(string const & input, CiteEngine const engine,
+ CiteEngineType const engine_type)
{
- string const default_str = defaultCiteCommand(engine);
+ string const default_str = defaultCiteCommand(engine, engine_type);
if (!InsetCitation::isCompatibleCommand(input))
return default_str;
output = default_str;
break;
- case ENGINE_NATBIB_AUTHORYEAR:
- case ENGINE_NATBIB_NUMERICAL:
+ case ENGINE_NATBIB:
if (input == "cite" || input == "citefield"
|| input == "citetitle" || input == "cite*")
output = default_str;
}
-inline docstring wrapCitation(docstring const & key,
+inline docstring wrapCitation(docstring const & key,
docstring const & content, bool for_xhtml)
{
if (!for_xhtml)
// CITE: author/<before field>
CiteEngine const engine = buffer().params().citeEngine();
+ CiteEngineType const engine_type = buffer().params().citeEngineType();
// We don't currently use the full or forceUCase fields.
- string cite_type = asValidLatexCommand(getCmdName(), engine);
+ string cite_type = asValidLatexCommand(getCmdName(), engine, engine_type);
if (cite_type[0] == 'C')
// If we were going to use them, this would mean ForceUCase
cite_type = string(1, 'c') + cite_type.substr(1);
else
label += wrapCitation(*it, author, for_xhtml) + sep_str;
}
- }
+ }
// nocite
else if (cite_type == "nocite") {
label += *it + sep_str;
- }
+ }
// (authors1 (<before> year); ... ;
// authors_last (<before> year, <after>)
else if (cite_type == "citet") {
switch (engine) {
- case ENGINE_NATBIB_AUTHORYEAR:
- label += author + op_str + before_str +
- wrapCitation(*it, year, for_xhtml) + cp + sep_str;
- break;
- case ENGINE_NATBIB_NUMERICAL:
- label += author + op_str + before_str +
- wrapCitation(*it, citenum, for_xhtml) + cp + sep_str;
+ case ENGINE_NATBIB:
+ if (engine_type == ENGINE_TYPE_AUTHORYEAR)
+ label += author + op_str + before_str +
+ wrapCitation(*it, year, for_xhtml) + cp + sep_str;
+ else
+ label += author + op_str + before_str +
+ wrapCitation(*it, citenum, for_xhtml) + cp + sep_str;
break;
case ENGINE_JURABIB:
label += before_str + author + op_str +
case ENGINE_BASIC:
break;
}
- }
- // author, year; author, year; ...
+ }
+ // author, year; author, year; ...
else if (cite_type == "citep" ||
cite_type == "citealp") {
- if (engine == ENGINE_NATBIB_NUMERICAL) {
+ if (engine_type == ENGINE_TYPE_NUMERICAL) {
label += wrapCitation(*it, citenum, for_xhtml) + sep_str;
} else {
label += wrapCitation(*it, author + ", " + year, for_xhtml) + sep_str;
}
- }
+ }
// (authors1 <before> year;
// authors_last <before> year, <after>)
else if (cite_type == "citealt") {
switch (engine) {
- case ENGINE_NATBIB_AUTHORYEAR:
- label += author + ' ' + before_str +
- wrapCitation(*it, year, for_xhtml) + sep_str;
- break;
- case ENGINE_NATBIB_NUMERICAL:
- label += author + ' ' + before_str + '#' +
- wrapCitation(*it, citenum, for_xhtml) + sep_str;
+ case ENGINE_NATBIB:
+ if (engine_type == ENGINE_TYPE_AUTHORYEAR)
+ label += author + ' ' + before_str +
+ wrapCitation(*it, year, for_xhtml) + sep_str;
+ else
+ label += author + ' ' + before_str + '#' +
+ wrapCitation(*it, citenum, for_xhtml) + sep_str;
break;
case ENGINE_JURABIB:
- label += before_str +
+ label += before_str +
wrapCitation(*it, author + ' ' + year, for_xhtml) + sep_str;
break;
case ENGINE_BASIC:
break;
}
-
- }
+
+ }
// author; author; ...
else if (cite_type == "citeauthor") {
label += wrapCitation(*it, author, for_xhtml) + sep_str;
label.insert(label.size() - 1, after_str);
} else {
bool const add =
- !(engine == ENGINE_NATBIB_NUMERICAL &&
+ !(engine == ENGINE_NATBIB &&
+ engine_type == ENGINE_TYPE_NUMERICAL &&
(cite_type == "citeauthor" ||
cite_type == "citeyear"));
if (add)
label = before_str + label;
}
- if (cite_type == "citep" || cite_type == "citeyearpar" ||
+ if (cite_type == "citep" || cite_type == "citeyearpar" ||
(cite_type == "cite" && engine == ENGINE_BASIC) )
label = op + label + cp;
void InsetCitation::latex(otexstream & os, OutputParams const & runparams) const
{
CiteEngine cite_engine = buffer().params().citeEngine();
+ CiteEngineType cite_engine_type = buffer().params().citeEngineType();
BiblioInfo const & bi = buffer().masterBibInfo();
// FIXME UNICODE
docstring const cite_str = from_utf8(
- asValidLatexCommand(getCmdName(), cite_engine));
+ asValidLatexCommand(getCmdName(), cite_engine, cite_engine_type));
if (runparams.inulemcmd)
os << "\\mbox{";
switch (features.bufferParams().citeEngine()) {
case ENGINE_BASIC:
break;
- case ENGINE_NATBIB_AUTHORYEAR:
- case ENGINE_NATBIB_NUMERICAL:
+ case ENGINE_NATBIB:
features.require("natbib");
break;
case ENGINE_JURABIB:
}
-docstring InsetCitation::contextMenuName() const
+string InsetCitation::contextMenuName() const
{
- return from_ascii("context-citation");
+ return "context-citation";
}