2002-04-24 10:00:39 +00:00
|
|
|
/**
|
2007-04-25 16:11:45 +00:00
|
|
|
* \file InsetCitation.cpp
|
2002-09-25 14:26:13 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2000-07-07 07:46:37 +00:00
|
|
|
*
|
2002-09-25 14:26:13 +00:00
|
|
|
* \author Angus Leeming
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Herbert Voß
|
2002-09-25 14:26:13 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-04-24 10:00:39 +00:00
|
|
|
*/
|
2000-06-07 08:53:40 +00:00
|
|
|
|
2000-07-07 07:46:37 +00:00
|
|
|
#include <config.h>
|
2000-06-07 08:53:40 +00:00
|
|
|
|
2007-04-25 16:11:45 +00:00
|
|
|
#include "InsetCitation.h"
|
2003-09-05 09:01:27 +00:00
|
|
|
|
2010-10-31 00:31:57 +00:00
|
|
|
#include "BiblioInfo.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "Buffer.h"
|
2008-03-10 15:01:57 +00:00
|
|
|
#include "buffer_funcs.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "BufferParams.h"
|
2009-03-25 12:23:43 +00:00
|
|
|
#include "BufferView.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "DispatchResult.h"
|
2011-05-07 23:02:53 +00:00
|
|
|
#include "FuncCode.h"
|
|
|
|
#include "FuncRequest.h"
|
2017-01-03 12:11:11 +00:00
|
|
|
#include "FuncStatus.h"
|
2001-07-19 14:12:37 +00:00
|
|
|
#include "LaTeXFeatures.h"
|
2009-11-30 22:59:18 +00:00
|
|
|
#include "output_xhtml.h"
|
2008-03-04 17:47:47 +00:00
|
|
|
#include "ParIterator.h"
|
2016-06-19 02:39:38 +00:00
|
|
|
#include "texstream.h"
|
2008-03-04 17:47:47 +00:00
|
|
|
#include "TocBackend.h"
|
2002-02-16 15:59:55 +00:00
|
|
|
|
2008-02-18 07:14:42 +00:00
|
|
|
#include "support/debug.h"
|
2007-11-28 22:12:03 +00:00
|
|
|
#include "support/docstream.h"
|
2008-04-19 15:52:35 +00:00
|
|
|
#include "support/FileNameList.h"
|
2008-03-04 17:47:47 +00:00
|
|
|
#include "support/gettext.h"
|
2008-02-18 07:14:42 +00:00
|
|
|
#include "support/lstrings.h"
|
2000-07-15 23:51:46 +00:00
|
|
|
|
2006-10-09 14:21:11 +00:00
|
|
|
#include <algorithm>
|
2014-05-23 14:59:12 +00:00
|
|
|
#include <climits>
|
2006-10-09 14:21:11 +00:00
|
|
|
|
2007-12-12 10:16:00 +00:00
|
|
|
using namespace std;
|
2007-12-12 18:57:56 +00:00
|
|
|
using namespace lyx::support;
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
2010-01-09 22:30:56 +00:00
|
|
|
InsetCitation::InsetCitation(Buffer * buf, InsetCommandParams const & p)
|
2010-10-29 00:46:21 +00:00
|
|
|
: InsetCommand(buf, p)
|
2013-01-12 00:04:07 +00:00
|
|
|
{
|
|
|
|
buffer().removeBiblioTempFiles();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
InsetCitation::~InsetCitation()
|
|
|
|
{
|
|
|
|
if (isBufferLoaded())
|
2017-04-07 10:04:02 +00:00
|
|
|
/* We do not use buffer() because Coverity believes that this
|
|
|
|
* may throw an exception. Actually this code path is not
|
|
|
|
* taken when buffer_ == 0 */
|
|
|
|
buffer_->removeBiblioTempFiles();
|
2013-01-12 00:04:07 +00:00
|
|
|
}
|
2010-01-09 22:30:56 +00:00
|
|
|
|
|
|
|
|
2018-02-22 20:24:28 +00:00
|
|
|
// May well be over-ridden when session settings are loaded
|
|
|
|
// in GuiCitation. Unfortunately, that will not happen until
|
|
|
|
// such a dialog is created.
|
|
|
|
bool InsetCitation::last_literal = true;
|
|
|
|
|
|
|
|
|
2010-01-09 22:30:56 +00:00
|
|
|
ParamInfo const & InsetCitation::findInfo(string const & /* cmdName */)
|
|
|
|
{
|
2018-02-22 06:00:18 +00:00
|
|
|
static ParamInfo param_info_;
|
|
|
|
|
2017-01-03 16:27:51 +00:00
|
|
|
// standard cite does only take one argument, but biblatex, jurabib
|
|
|
|
// and natbib extend this to two arguments, so
|
2010-01-09 22:30:56 +00:00
|
|
|
// we have to allow both here. InsetCitation takes care that
|
|
|
|
// LaTeX output is nevertheless correct.
|
|
|
|
if (param_info_.empty()) {
|
2017-01-30 06:44:55 +00:00
|
|
|
param_info_.add("after", ParamInfo::LATEX_OPTIONAL,
|
|
|
|
ParamInfo::HANDLING_LATEXIFY);
|
|
|
|
param_info_.add("before", ParamInfo::LATEX_OPTIONAL,
|
|
|
|
ParamInfo::HANDLING_LATEXIFY);
|
2010-01-09 22:30:56 +00:00
|
|
|
param_info_.add("key", ParamInfo::LATEX_REQUIRED);
|
2017-01-30 06:44:55 +00:00
|
|
|
param_info_.add("pretextlist", ParamInfo::LATEX_OPTIONAL,
|
|
|
|
ParamInfo::HANDLING_LATEXIFY);
|
|
|
|
param_info_.add("posttextlist", ParamInfo::LATEX_OPTIONAL,
|
|
|
|
ParamInfo::HANDLING_LATEXIFY);
|
|
|
|
param_info_.add("literal", ParamInfo::LYX_INTERNAL);
|
2010-01-09 22:30:56 +00:00
|
|
|
}
|
|
|
|
return param_info_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-03 16:27:51 +00:00
|
|
|
// We allow any command here, since we fall back to cite
|
|
|
|
// anyway if a command is not allowed by a style
|
|
|
|
bool InsetCitation::isCompatibleCommand(string const &)
|
2007-08-20 16:30:02 +00:00
|
|
|
{
|
2017-01-03 16:27:51 +00:00
|
|
|
return true;
|
2010-01-09 22:30:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-07 16:37:35 +00:00
|
|
|
CitationStyle InsetCitation::getCitationStyle(BufferParams const & bp, string const & input,
|
|
|
|
vector<CitationStyle> const & valid_styles) const
|
|
|
|
{
|
|
|
|
CitationStyle cs = valid_styles[0];
|
|
|
|
cs.forceUpperCase = false;
|
|
|
|
cs.hasStarredVersion = false;
|
|
|
|
|
|
|
|
string normalized_input = input;
|
|
|
|
string::size_type const n = input.size() - 1;
|
|
|
|
if (isUpperCase(input[0]))
|
|
|
|
normalized_input[0] = lowercase(input[0]);
|
|
|
|
if (input[n] == '*')
|
|
|
|
normalized_input = normalized_input.substr(0, n);
|
|
|
|
|
|
|
|
string const alias = bp.getCiteAlias(normalized_input);
|
|
|
|
if (!alias.empty())
|
|
|
|
normalized_input = alias;
|
|
|
|
|
|
|
|
vector<CitationStyle>::const_iterator it = valid_styles.begin();
|
|
|
|
vector<CitationStyle>::const_iterator end = valid_styles.end();
|
|
|
|
for (; it != end; ++it) {
|
|
|
|
CitationStyle this_cs = *it;
|
|
|
|
if (this_cs.name == normalized_input) {
|
|
|
|
cs = *it;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return cs;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-05-07 23:02:53 +00:00
|
|
|
void InsetCitation::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|
|
|
{
|
2017-01-07 16:37:35 +00:00
|
|
|
switch (cmd.action()) {
|
|
|
|
case LFUN_INSET_MODIFY: {
|
2013-01-12 00:04:07 +00:00
|
|
|
buffer().removeBiblioTempFiles();
|
2011-05-07 23:02:53 +00:00
|
|
|
cache.recalculate = true;
|
2017-01-07 16:37:35 +00:00
|
|
|
if (cmd.getArg(0) == "toggleparam") {
|
|
|
|
string cmdname = getCmdName();
|
|
|
|
string const alias =
|
2017-01-14 13:44:18 +00:00
|
|
|
buffer().masterParams().getCiteAlias(cmdname);
|
2017-01-07 16:37:35 +00:00
|
|
|
if (!alias.empty())
|
|
|
|
cmdname = alias;
|
|
|
|
string const par = cmd.getArg(1);
|
|
|
|
string newcmdname = cmdname;
|
|
|
|
if (par == "star") {
|
|
|
|
if (suffixIs(cmdname, "*"))
|
|
|
|
newcmdname = rtrim(cmdname, "*");
|
|
|
|
else
|
|
|
|
newcmdname = cmdname + "*";
|
|
|
|
} else if (par == "casing") {
|
|
|
|
if (isUpperCase(cmdname[0]))
|
|
|
|
newcmdname[0] = lowercase(cmdname[0]);
|
|
|
|
else
|
|
|
|
newcmdname[0] = uppercase(newcmdname[0]);
|
|
|
|
}
|
|
|
|
cmd = FuncRequest(LFUN_INSET_MODIFY, "changetype " + newcmdname);
|
|
|
|
}
|
|
|
|
}
|
2018-01-29 04:02:30 +00:00
|
|
|
// fall through
|
2017-01-07 16:37:35 +00:00
|
|
|
default:
|
|
|
|
InsetCommand::doDispatch(cur, cmd);
|
2013-01-12 00:04:07 +00:00
|
|
|
}
|
2011-05-07 23:02:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-03 12:11:11 +00:00
|
|
|
bool InsetCitation::getStatus(Cursor & cur, FuncRequest const & cmd,
|
|
|
|
FuncStatus & status) const
|
|
|
|
{
|
|
|
|
switch (cmd.action()) {
|
|
|
|
// Handle the alias case
|
|
|
|
case LFUN_INSET_MODIFY:
|
|
|
|
if (cmd.getArg(0) == "changetype") {
|
|
|
|
string cmdname = getCmdName();
|
2017-01-07 16:37:35 +00:00
|
|
|
string const alias =
|
2017-01-14 13:44:18 +00:00
|
|
|
buffer().masterParams().getCiteAlias(cmdname);
|
2017-01-03 12:11:11 +00:00
|
|
|
if (!alias.empty())
|
|
|
|
cmdname = alias;
|
2017-01-07 16:37:35 +00:00
|
|
|
if (suffixIs(cmdname, "*"))
|
|
|
|
cmdname = rtrim(cmdname, "*");
|
2017-01-03 12:11:11 +00:00
|
|
|
string const newtype = cmd.getArg(1);
|
|
|
|
status.setEnabled(isCompatibleCommand(newtype));
|
|
|
|
status.setOnOff(newtype == cmdname);
|
|
|
|
}
|
2017-01-07 16:37:35 +00:00
|
|
|
if (cmd.getArg(0) == "toggleparam") {
|
|
|
|
string cmdname = getCmdName();
|
|
|
|
string const alias =
|
2017-01-14 13:44:18 +00:00
|
|
|
buffer().masterParams().getCiteAlias(cmdname);
|
2017-01-07 16:37:35 +00:00
|
|
|
if (!alias.empty())
|
|
|
|
cmdname = alias;
|
|
|
|
vector<CitationStyle> citation_styles =
|
2017-01-14 13:44:18 +00:00
|
|
|
buffer().masterParams().citeStyles();
|
|
|
|
CitationStyle cs = getCitationStyle(buffer().masterParams(),
|
2017-01-07 16:37:35 +00:00
|
|
|
cmdname, citation_styles);
|
|
|
|
if (cmd.getArg(1) == "star") {
|
|
|
|
status.setEnabled(cs.hasStarredVersion);
|
|
|
|
status.setOnOff(suffixIs(cmdname, "*"));
|
|
|
|
}
|
|
|
|
else if (cmd.getArg(1) == "casing") {
|
|
|
|
status.setEnabled(cs.forceUpperCase);
|
|
|
|
status.setOnOff(isUpperCase(cmdname[0]));
|
|
|
|
}
|
|
|
|
}
|
2017-01-03 12:11:11 +00:00
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return InsetCommand::getStatus(cur, cmd, status);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-06-05 08:37:34 +00:00
|
|
|
bool InsetCitation::addKey(string const & key)
|
|
|
|
{
|
|
|
|
docstring const ukey = from_utf8(key);
|
|
|
|
docstring const & curkeys = getParam("key");
|
|
|
|
if (curkeys.empty()) {
|
|
|
|
setParam("key", ukey);
|
|
|
|
cache.recalculate = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
vector<docstring> keys = getVectorFromString(curkeys);
|
|
|
|
vector<docstring>::const_iterator it = keys.begin();
|
|
|
|
vector<docstring>::const_iterator en = keys.end();
|
|
|
|
for (; it != en; ++it) {
|
|
|
|
if (*it == ukey) {
|
|
|
|
LYXERR0("Key " << key << " already present.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
keys.push_back(ukey);
|
|
|
|
setParam("key", getStringFromVector(keys));
|
|
|
|
cache.recalculate = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-09 22:30:56 +00:00
|
|
|
docstring InsetCitation::toolTip(BufferView const & bv, int, int) const
|
|
|
|
{
|
|
|
|
Buffer const & buf = bv.buffer();
|
|
|
|
// Only after the buffer is loaded from file...
|
|
|
|
if (!buf.isFullyLoaded())
|
|
|
|
return docstring();
|
|
|
|
|
|
|
|
BiblioInfo const & bi = buf.masterBibInfo();
|
|
|
|
if (bi.empty())
|
|
|
|
return _("No bibliography defined!");
|
|
|
|
|
|
|
|
docstring const & key = getParam("key");
|
|
|
|
if (key.empty())
|
|
|
|
return _("No citations selected!");
|
|
|
|
|
2017-01-07 16:12:08 +00:00
|
|
|
CiteItem ci;
|
|
|
|
ci.richtext = true;
|
2010-01-09 22:30:56 +00:00
|
|
|
vector<docstring> keys = getVectorFromString(key);
|
2016-06-11 11:57:18 +00:00
|
|
|
if (keys.size() == 1)
|
2017-01-07 16:12:08 +00:00
|
|
|
return bi.getInfo(keys[0], buffer(), ci);
|
2016-06-11 11:57:18 +00:00
|
|
|
|
2010-01-09 22:30:56 +00:00
|
|
|
docstring tip;
|
2016-06-11 11:57:18 +00:00
|
|
|
tip += "<ol>";
|
2017-01-07 16:38:25 +00:00
|
|
|
int count = 0;
|
2017-12-16 14:30:12 +00:00
|
|
|
for (docstring const & kvar : keys) {
|
|
|
|
docstring const key_info = bi.getInfo(kvar, buffer(), ci);
|
2017-01-07 16:38:25 +00:00
|
|
|
// limit to reasonable size.
|
|
|
|
if (count > 9 && keys.size() > 11) {
|
|
|
|
tip.push_back(0x2026);// HORIZONTAL ELLIPSIS
|
|
|
|
tip += "<p>"
|
|
|
|
+ bformat(_("+ %1$d more entries."), int(keys.size() - count))
|
|
|
|
+ "</p>";
|
|
|
|
break;
|
|
|
|
}
|
2010-01-09 22:30:56 +00:00
|
|
|
if (key_info.empty())
|
|
|
|
continue;
|
2016-06-11 11:57:18 +00:00
|
|
|
tip += "<li>" + key_info + "</li>";
|
2017-01-07 16:38:25 +00:00
|
|
|
++count;
|
2010-01-09 22:30:56 +00:00
|
|
|
}
|
2016-06-11 11:57:18 +00:00
|
|
|
tip += "</ol>";
|
2010-01-09 22:30:56 +00:00
|
|
|
return tip;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
namespace {
|
2011-12-03 22:15:11 +00:00
|
|
|
|
2017-01-03 12:11:11 +00:00
|
|
|
CitationStyle asValidLatexCommand(BufferParams const & bp, string const & input,
|
|
|
|
vector<CitationStyle> const & valid_styles)
|
2007-08-20 16:30:02 +00:00
|
|
|
{
|
2012-03-01 00:41:30 +00:00
|
|
|
CitationStyle cs = valid_styles[0];
|
|
|
|
cs.forceUpperCase = false;
|
2017-01-03 16:25:41 +00:00
|
|
|
cs.hasStarredVersion = false;
|
2007-09-20 06:22:07 +00:00
|
|
|
|
2012-03-01 00:41:30 +00:00
|
|
|
string normalized_input = input;
|
|
|
|
string::size_type const n = input.size() - 1;
|
2017-01-03 09:17:09 +00:00
|
|
|
if (isUpperCase(input[0]))
|
|
|
|
normalized_input[0] = lowercase(input[0]);
|
2012-03-01 00:41:30 +00:00
|
|
|
if (input[n] == '*')
|
|
|
|
normalized_input = normalized_input.substr(0, n);
|
2007-09-20 06:22:07 +00:00
|
|
|
|
2017-01-03 12:11:11 +00:00
|
|
|
string const alias = bp.getCiteAlias(normalized_input);
|
|
|
|
if (!alias.empty())
|
|
|
|
normalized_input = alias;
|
|
|
|
|
2012-03-01 00:41:30 +00:00
|
|
|
vector<CitationStyle>::const_iterator it = valid_styles.begin();
|
|
|
|
vector<CitationStyle>::const_iterator end = valid_styles.end();
|
|
|
|
for (; it != end; ++it) {
|
|
|
|
CitationStyle this_cs = *it;
|
2017-01-03 12:11:11 +00:00
|
|
|
if (this_cs.name == normalized_input) {
|
2012-03-01 00:41:30 +00:00
|
|
|
cs = *it;
|
2007-09-20 06:22:07 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-08-20 16:30:02 +00:00
|
|
|
}
|
|
|
|
|
2017-01-03 09:17:09 +00:00
|
|
|
cs.forceUpperCase &= input[0] == uppercase(input[0]);
|
2017-01-03 16:25:41 +00:00
|
|
|
cs.hasStarredVersion &= input[n] == '*';
|
2012-03-01 00:41:30 +00:00
|
|
|
|
|
|
|
return cs;
|
2007-08-20 16:30:02 +00:00
|
|
|
}
|
|
|
|
|
2010-01-11 16:11:55 +00:00
|
|
|
|
2011-12-03 22:15:11 +00:00
|
|
|
inline docstring wrapCitation(docstring const & key,
|
2010-01-11 16:11:55 +00:00
|
|
|
docstring const & content, bool for_xhtml)
|
|
|
|
{
|
|
|
|
if (!for_xhtml)
|
|
|
|
return content;
|
|
|
|
// we have to do the escaping here, because we will ultimately
|
|
|
|
// write this as a raw string, so as not to escape the tags.
|
2013-03-27 19:46:32 +00:00
|
|
|
return "<a href='#LyXCite-" + html::cleanAttr(key) + "'>" +
|
2010-11-24 15:27:36 +00:00
|
|
|
html::htmlize(content, XHTMLStream::ESCAPE_ALL) + "</a>";
|
2010-01-11 16:11:55 +00:00
|
|
|
}
|
|
|
|
|
2010-01-09 22:30:56 +00:00
|
|
|
} // anonymous namespace
|
2010-01-09 22:30:12 +00:00
|
|
|
|
Support for "qualified citation lists"
These are biblatex-specific multicite commands that allow for multiple
pre- and postnotes, as in:
\cites(pre)(post)[pre1][post1]{key1}[pre2][post2]{key2}...
with an optional general pre- and postnote, which applies to the whole
list (like [][] in normal cite commands) and an optional pre- and
postnotes for each item, so that pagination can actually be specified in
multi-cite references, as in:
(cf. Miller 2015, 2; furthermore Smith 2013, 23-23; Jenkins 2012, 103,
also refer to chapter 6 in this book)
See the biblatex manual, sec. 3.8.3., for details.
File format change.
2017-01-21 13:25:17 +00:00
|
|
|
|
2019-08-07 11:00:29 +00:00
|
|
|
vector<pair<docstring, docstring>> InsetCitation::getQualifiedLists(docstring const p) const
|
Support for "qualified citation lists"
These are biblatex-specific multicite commands that allow for multiple
pre- and postnotes, as in:
\cites(pre)(post)[pre1][post1]{key1}[pre2][post2]{key2}...
with an optional general pre- and postnote, which applies to the whole
list (like [][] in normal cite commands) and an optional pre- and
postnotes for each item, so that pagination can actually be specified in
multi-cite references, as in:
(cf. Miller 2015, 2; furthermore Smith 2013, 23-23; Jenkins 2012, 103,
also refer to chapter 6 in this book)
See the biblatex manual, sec. 3.8.3., for details.
File format change.
2017-01-21 13:25:17 +00:00
|
|
|
{
|
|
|
|
vector<docstring> ps =
|
|
|
|
getVectorFromString(p, from_ascii("\t"));
|
2019-08-07 11:00:29 +00:00
|
|
|
QualifiedList res;
|
Support for "qualified citation lists"
These are biblatex-specific multicite commands that allow for multiple
pre- and postnotes, as in:
\cites(pre)(post)[pre1][post1]{key1}[pre2][post2]{key2}...
with an optional general pre- and postnote, which applies to the whole
list (like [][] in normal cite commands) and an optional pre- and
postnotes for each item, so that pagination can actually be specified in
multi-cite references, as in:
(cf. Miller 2015, 2; furthermore Smith 2013, 23-23; Jenkins 2012, 103,
also refer to chapter 6 in this book)
See the biblatex manual, sec. 3.8.3., for details.
File format change.
2017-01-21 13:25:17 +00:00
|
|
|
for (docstring const & s: ps) {
|
2019-08-07 11:00:29 +00:00
|
|
|
docstring key = s;
|
|
|
|
docstring val;
|
|
|
|
if (contains(s, ' '))
|
|
|
|
val = split(s, key, ' ');
|
|
|
|
res.push_back(make_pair(key, val));
|
Support for "qualified citation lists"
These are biblatex-specific multicite commands that allow for multiple
pre- and postnotes, as in:
\cites(pre)(post)[pre1][post1]{key1}[pre2][post2]{key2}...
with an optional general pre- and postnote, which applies to the whole
list (like [][] in normal cite commands) and an optional pre- and
postnotes for each item, so that pagination can actually be specified in
multi-cite references, as in:
(cf. Miller 2015, 2; furthermore Smith 2013, 23-23; Jenkins 2012, 103,
also refer to chapter 6 in this book)
See the biblatex manual, sec. 3.8.3., for details.
File format change.
2017-01-21 13:25:17 +00:00
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2010-01-11 16:11:55 +00:00
|
|
|
docstring InsetCitation::generateLabel(bool for_xhtml) const
|
2010-01-09 22:30:12 +00:00
|
|
|
{
|
|
|
|
docstring label;
|
2010-01-11 16:11:55 +00:00
|
|
|
label = complexLabel(for_xhtml);
|
2010-01-09 22:30:12 +00:00
|
|
|
|
|
|
|
// Fallback to fail-safe
|
|
|
|
if (label.empty())
|
2010-01-11 16:11:55 +00:00
|
|
|
label = basicLabel(for_xhtml);
|
2010-01-09 22:30:12 +00:00
|
|
|
|
|
|
|
return label;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-11 16:11:55 +00:00
|
|
|
docstring InsetCitation::complexLabel(bool for_xhtml) const
|
2000-06-07 08:53:40 +00:00
|
|
|
{
|
2010-01-09 22:30:12 +00:00
|
|
|
Buffer const & buf = buffer();
|
2003-10-22 13:15:18 +00:00
|
|
|
// Only start the process off after the buffer is loaded from file.
|
2010-01-09 22:30:12 +00:00
|
|
|
if (!buf.isFullyLoaded())
|
2006-12-17 10:52:04 +00:00
|
|
|
return docstring();
|
2003-10-22 13:15:18 +00:00
|
|
|
|
2010-01-09 22:30:12 +00:00
|
|
|
BiblioInfo const & biblist = buf.masterBibInfo();
|
2007-08-20 16:30:02 +00:00
|
|
|
if (biblist.empty())
|
2006-12-17 10:52:04 +00:00
|
|
|
return docstring();
|
2002-07-28 18:13:51 +00:00
|
|
|
|
2012-03-01 00:41:30 +00:00
|
|
|
docstring const & key = getParam("key");
|
|
|
|
if (key.empty())
|
|
|
|
return _("No citations selected!");
|
|
|
|
|
|
|
|
string cite_type = getCmdName();
|
2017-01-07 16:21:41 +00:00
|
|
|
bool const uppercase = isUpperCase(cite_type[0]);
|
|
|
|
if (uppercase)
|
2017-01-03 09:17:09 +00:00
|
|
|
cite_type[0] = lowercase(cite_type[0]);
|
2017-01-07 16:32:45 +00:00
|
|
|
bool const starred = (cite_type[cite_type.size() - 1] == '*');
|
|
|
|
if (starred)
|
2004-05-14 15:27:13 +00:00
|
|
|
cite_type = cite_type.substr(0, cite_type.size() - 1);
|
2002-07-28 18:13:51 +00:00
|
|
|
|
2017-01-03 12:11:11 +00:00
|
|
|
// handle alias
|
2017-01-14 13:44:18 +00:00
|
|
|
string const alias = buf.masterParams().getCiteAlias(cite_type);
|
2017-01-03 12:11:11 +00:00
|
|
|
if (!alias.empty())
|
|
|
|
cite_type = alias;
|
|
|
|
|
2012-03-01 00:41:30 +00:00
|
|
|
// FIXME: allow to add cite macros
|
|
|
|
/*
|
|
|
|
buffer().params().documentClass().addCiteMacro("!textbefore", to_utf8(before));
|
|
|
|
buffer().params().documentClass().addCiteMacro("!textafter", to_utf8(after));
|
|
|
|
*/
|
2006-12-17 10:52:04 +00:00
|
|
|
docstring label;
|
2017-10-18 16:26:35 +00:00
|
|
|
// we only really want the last 'false', to suppress trimming, but
|
|
|
|
// we need to give the other defaults, too, to set it.
|
|
|
|
vector<docstring> keys =
|
|
|
|
getVectorFromString(key, from_ascii(","), false, false);
|
Support for "qualified citation lists"
These are biblatex-specific multicite commands that allow for multiple
pre- and postnotes, as in:
\cites(pre)(post)[pre1][post1]{key1}[pre2][post2]{key2}...
with an optional general pre- and postnote, which applies to the whole
list (like [][] in normal cite commands) and an optional pre- and
postnotes for each item, so that pagination can actually be specified in
multi-cite references, as in:
(cf. Miller 2015, 2; furthermore Smith 2013, 23-23; Jenkins 2012, 103,
also refer to chapter 6 in this book)
See the biblatex manual, sec. 3.8.3., for details.
File format change.
2017-01-21 13:25:17 +00:00
|
|
|
CitationStyle cs = getCitationStyle(buffer().masterParams(),
|
2017-10-18 16:26:35 +00:00
|
|
|
cite_type, buffer().masterParams().citeStyles());
|
Support for "qualified citation lists"
These are biblatex-specific multicite commands that allow for multiple
pre- and postnotes, as in:
\cites(pre)(post)[pre1][post1]{key1}[pre2][post2]{key2}...
with an optional general pre- and postnote, which applies to the whole
list (like [][] in normal cite commands) and an optional pre- and
postnotes for each item, so that pagination can actually be specified in
multi-cite references, as in:
(cf. Miller 2015, 2; furthermore Smith 2013, 23-23; Jenkins 2012, 103,
also refer to chapter 6 in this book)
See the biblatex manual, sec. 3.8.3., for details.
File format change.
2017-01-21 13:25:17 +00:00
|
|
|
bool const qualified = cs.hasQualifiedList
|
|
|
|
&& (keys.size() > 1
|
|
|
|
|| !getParam("pretextlist").empty()
|
|
|
|
|| !getParam("posttextlist").empty());
|
2019-08-07 11:00:29 +00:00
|
|
|
QualifiedList pres = getQualifiedLists(getParam("pretextlist"));
|
|
|
|
QualifiedList posts = getQualifiedLists(getParam("posttextlist"));
|
Support for "qualified citation lists"
These are biblatex-specific multicite commands that allow for multiple
pre- and postnotes, as in:
\cites(pre)(post)[pre1][post1]{key1}[pre2][post2]{key2}...
with an optional general pre- and postnote, which applies to the whole
list (like [][] in normal cite commands) and an optional pre- and
postnotes for each item, so that pagination can actually be specified in
multi-cite references, as in:
(cf. Miller 2015, 2; furthermore Smith 2013, 23-23; Jenkins 2012, 103,
also refer to chapter 6 in this book)
See the biblatex manual, sec. 3.8.3., for details.
File format change.
2017-01-21 13:25:17 +00:00
|
|
|
|
2017-01-07 16:12:08 +00:00
|
|
|
CiteItem ci;
|
|
|
|
ci.textBefore = getParam("before");
|
|
|
|
ci.textAfter = getParam("after");
|
2017-01-07 16:21:41 +00:00
|
|
|
ci.forceUpperCase = uppercase;
|
2017-01-07 16:32:45 +00:00
|
|
|
ci.Starred = starred;
|
2017-01-07 16:12:08 +00:00
|
|
|
ci.max_size = UINT_MAX;
|
Support for "qualified citation lists"
These are biblatex-specific multicite commands that allow for multiple
pre- and postnotes, as in:
\cites(pre)(post)[pre1][post1]{key1}[pre2][post2]{key2}...
with an optional general pre- and postnote, which applies to the whole
list (like [][] in normal cite commands) and an optional pre- and
postnotes for each item, so that pagination can actually be specified in
multi-cite references, as in:
(cf. Miller 2015, 2; furthermore Smith 2013, 23-23; Jenkins 2012, 103,
also refer to chapter 6 in this book)
See the biblatex manual, sec. 3.8.3., for details.
File format change.
2017-01-21 13:25:17 +00:00
|
|
|
ci.isQualified = qualified;
|
|
|
|
ci.pretexts = pres;
|
|
|
|
ci.posttexts = posts;
|
2017-01-07 16:12:08 +00:00
|
|
|
if (for_xhtml) {
|
|
|
|
ci.max_key_size = UINT_MAX;
|
|
|
|
ci.context = CiteItem::Export;
|
|
|
|
}
|
|
|
|
ci.richtext = for_xhtml;
|
|
|
|
label = biblist.getLabel(keys, buffer(), cite_type, ci);
|
2002-04-24 10:00:39 +00:00
|
|
|
return label;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-11 16:11:55 +00:00
|
|
|
docstring InsetCitation::basicLabel(bool for_xhtml) const
|
2002-04-24 10:00:39 +00:00
|
|
|
{
|
2010-01-09 22:30:12 +00:00
|
|
|
docstring keys = getParam("key");
|
2006-12-17 10:52:04 +00:00
|
|
|
docstring label;
|
2002-04-24 10:00:39 +00:00
|
|
|
|
2010-01-21 19:58:21 +00:00
|
|
|
docstring key;
|
|
|
|
do {
|
|
|
|
// if there is no comma, then everything goes into key
|
|
|
|
// and keys will be empty.
|
2017-10-19 14:15:03 +00:00
|
|
|
keys = split(keys, key, ',');
|
2010-01-21 19:58:21 +00:00
|
|
|
if (!label.empty())
|
|
|
|
label += ", ";
|
|
|
|
label += wrapCitation(key, key, for_xhtml);
|
|
|
|
} while (!keys.empty());
|
2002-04-24 10:00:39 +00:00
|
|
|
|
2010-01-09 22:30:12 +00:00
|
|
|
docstring const & after = getParam("after");
|
2002-04-24 10:00:39 +00:00
|
|
|
if (!after.empty())
|
|
|
|
label += ", " + after;
|
2002-07-28 18:13:51 +00:00
|
|
|
|
2002-11-27 10:30:28 +00:00
|
|
|
return '[' + label + ']';
|
2002-04-24 10:00:39 +00:00
|
|
|
}
|
|
|
|
|
2019-08-11 06:15:57 +00:00
|
|
|
|
|
|
|
bool InsetCitation::forceLTR(OutputParams const & rp) const
|
|
|
|
{
|
|
|
|
// We have to force LTR for numeric references
|
2019-08-11 06:21:33 +00:00
|
|
|
// [= bibliography, plain BibTeX, numeric natbib
|
|
|
|
// and biblatex]. Except for XeTeX/bidi. See #3005.
|
2019-08-11 06:15:57 +00:00
|
|
|
if (rp.useBidiPackage())
|
|
|
|
return false;
|
|
|
|
return (buffer().masterParams().citeEngine() == "basic"
|
|
|
|
|| buffer().masterParams().citeEngineType() == ENGINE_TYPE_NUMERICAL);
|
|
|
|
}
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
docstring InsetCitation::screenLabel() const
|
2008-03-04 17:47:47 +00:00
|
|
|
{
|
|
|
|
return cache.screen_label;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-03-03 22:13:45 +00:00
|
|
|
void InsetCitation::updateBuffer(ParIterator const &, UpdateType)
|
2002-04-24 10:00:39 +00:00
|
|
|
{
|
2011-05-07 23:02:53 +00:00
|
|
|
if (!cache.recalculate && buffer().citeLabelsValid())
|
2008-03-04 17:47:47 +00:00
|
|
|
return;
|
2011-05-07 23:02:53 +00:00
|
|
|
// The label may have changed, so we have to re-create it.
|
2008-02-27 20:43:16 +00:00
|
|
|
docstring const glabel = generateLabel();
|
2011-05-07 23:02:53 +00:00
|
|
|
cache.recalculate = false;
|
2002-04-24 10:00:39 +00:00
|
|
|
cache.generated_label = glabel;
|
2015-10-04 18:38:47 +00:00
|
|
|
unsigned int const maxLabelChars = 45;
|
2019-07-09 12:48:11 +00:00
|
|
|
cache.screen_label = glabel;
|
|
|
|
support::truncateWithEllipsis(cache.screen_label, maxLabelChars, true);
|
2008-03-04 17:47:47 +00:00
|
|
|
}
|
2002-04-24 10:00:39 +00:00
|
|
|
|
2008-03-04 17:47:47 +00:00
|
|
|
|
2015-09-27 06:05:00 +00:00
|
|
|
void InsetCitation::addToToc(DocIterator const & cpit, bool output_active,
|
2017-01-13 10:06:48 +00:00
|
|
|
UpdateType, TocBackend & backend) const
|
2008-03-04 17:47:47 +00:00
|
|
|
{
|
2010-07-30 15:50:42 +00:00
|
|
|
// NOTE
|
2017-07-03 17:53:14 +00:00
|
|
|
// BiblioInfo::collectCitedEntries() uses the TOC to collect the citations
|
2014-08-22 15:17:36 +00:00
|
|
|
// from the document. It is used indirectly, via BiblioInfo::makeCitationLables,
|
|
|
|
// by both XHTML and plaintext output. So, if we change what goes into the TOC,
|
|
|
|
// then we will also need to change that routine.
|
2010-07-30 15:50:42 +00:00
|
|
|
docstring const tocitem = getParam("key");
|
2017-01-13 10:06:48 +00:00
|
|
|
TocBuilder & b = backend.builder("citation");
|
2017-01-09 16:37:50 +00:00
|
|
|
b.pushItem(cpit, tocitem, output_active);
|
|
|
|
b.pop();
|
2000-06-07 08:53:40 +00:00
|
|
|
}
|
2000-07-14 07:52:03 +00:00
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
|
2013-03-08 19:52:18 +00:00
|
|
|
int InsetCitation::plaintext(odocstringstream & os,
|
|
|
|
OutputParams const &, size_t) const
|
2001-05-27 17:51:16 +00:00
|
|
|
{
|
2013-02-02 18:23:21 +00:00
|
|
|
string const & cmd = getCmdName();
|
|
|
|
if (cmd == "nocite")
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
docstring const label = generateLabel(false);
|
|
|
|
os << label;
|
|
|
|
return label.size();
|
2001-05-27 17:51:16 +00:00
|
|
|
}
|
2001-07-19 14:12:37 +00:00
|
|
|
|
2002-04-24 10:00:39 +00:00
|
|
|
|
2007-09-11 22:31:24 +00:00
|
|
|
static docstring const cleanupWhitespace(docstring const & citelist)
|
2004-10-21 22:39:20 +00:00
|
|
|
{
|
2006-12-17 10:52:04 +00:00
|
|
|
docstring::const_iterator it = citelist.begin();
|
|
|
|
docstring::const_iterator end = citelist.end();
|
2004-10-21 22:39:20 +00:00
|
|
|
// Paranoia check: make sure that there is no whitespace in here
|
|
|
|
// -- at least not behind commas or at the beginning
|
2006-12-17 10:52:04 +00:00
|
|
|
docstring result;
|
|
|
|
char_type last = ',';
|
2004-10-21 22:39:20 +00:00
|
|
|
for (; it != end; ++it) {
|
|
|
|
if (*it != ' ')
|
|
|
|
last = *it;
|
|
|
|
if (*it != ' ' || last != ',')
|
|
|
|
result += *it;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
int InsetCitation::docbook(odocstream & os, OutputParams const &) const
|
2004-10-21 22:39:20 +00:00
|
|
|
{
|
2007-11-28 22:12:03 +00:00
|
|
|
os << from_ascii("<citation>")
|
2007-05-28 22:27:45 +00:00
|
|
|
<< cleanupWhitespace(getParam("key"))
|
2007-11-28 22:12:03 +00:00
|
|
|
<< from_ascii("</citation>");
|
2004-10-21 22:39:20 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-30 22:59:18 +00:00
|
|
|
docstring InsetCitation::xhtml(XHTMLStream & xs, OutputParams const &) const
|
2009-06-11 21:04:15 +00:00
|
|
|
{
|
2010-01-08 18:49:32 +00:00
|
|
|
string const & cmd = getCmdName();
|
|
|
|
if (cmd == "nocite")
|
|
|
|
return docstring();
|
|
|
|
|
2010-01-11 16:11:55 +00:00
|
|
|
// have to output this raw, because generateLabel() will include tags
|
2010-11-24 15:27:36 +00:00
|
|
|
xs << XHTMLStream::ESCAPE_NONE << generateLabel(true);
|
2009-06-11 21:04:15 +00:00
|
|
|
|
2009-06-12 17:23:17 +00:00
|
|
|
return docstring();
|
2009-06-11 21:04:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-15 01:34:04 +00:00
|
|
|
void InsetCitation::toString(odocstream & os) const
|
2005-11-25 14:40:34 +00:00
|
|
|
{
|
2013-03-08 19:52:18 +00:00
|
|
|
odocstringstream ods;
|
|
|
|
plaintext(ods, OutputParams(0));
|
|
|
|
os << ods.str();
|
2005-11-25 14:40:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-10-04 18:38:47 +00:00
|
|
|
void InsetCitation::forOutliner(docstring & os, size_t const, bool const) const
|
2010-12-20 21:55:09 +00:00
|
|
|
{
|
|
|
|
os += screenLabel();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-19 14:12:37 +00:00
|
|
|
// Have to overwrite the default InsetCommand method in order to check that
|
|
|
|
// the \cite command is valid. Eg, the user has natbib enabled, inputs some
|
|
|
|
// citations and then changes his mind, turning natbib support off. The output
|
2012-03-01 00:41:30 +00:00
|
|
|
// should revert to the default citation command as provided by the citation
|
|
|
|
// engine, e.g. \cite[]{} for the basic engine.
|
2011-02-10 20:02:48 +00:00
|
|
|
void InsetCitation::latex(otexstream & os, OutputParams const & runparams) const
|
2001-07-19 14:12:37 +00:00
|
|
|
{
|
2018-03-22 22:37:19 +00:00
|
|
|
// When this is a child compiled on its own, we use the childs
|
|
|
|
// own bibinfo, else the master's
|
2018-03-22 14:52:23 +00:00
|
|
|
BiblioInfo const & bi = runparams.is_child
|
|
|
|
? buffer().masterBibInfo() : buffer().bibInfo();
|
Support for "qualified citation lists"
These are biblatex-specific multicite commands that allow for multiple
pre- and postnotes, as in:
\cites(pre)(post)[pre1][post1]{key1}[pre2][post2]{key2}...
with an optional general pre- and postnote, which applies to the whole
list (like [][] in normal cite commands) and an optional pre- and
postnotes for each item, so that pagination can actually be specified in
multi-cite references, as in:
(cf. Miller 2015, 2; furthermore Smith 2013, 23-23; Jenkins 2012, 103,
also refer to chapter 6 in this book)
See the biblatex manual, sec. 3.8.3., for details.
File format change.
2017-01-21 13:25:17 +00:00
|
|
|
docstring const key = getParam("key");
|
|
|
|
// "keyonly" command: output the plain key and stop.
|
2017-01-13 10:53:22 +00:00
|
|
|
if (getCmdName() == "keyonly") {
|
|
|
|
// Special command to only return the key
|
|
|
|
if (!bi.isBibtex(getParam("key")))
|
|
|
|
// escape chars with bibitems
|
Support for "qualified citation lists"
These are biblatex-specific multicite commands that allow for multiple
pre- and postnotes, as in:
\cites(pre)(post)[pre1][post1]{key1}[pre2][post2]{key2}...
with an optional general pre- and postnote, which applies to the whole
list (like [][] in normal cite commands) and an optional pre- and
postnotes for each item, so that pagination can actually be specified in
multi-cite references, as in:
(cf. Miller 2015, 2; furthermore Smith 2013, 23-23; Jenkins 2012, 103,
also refer to chapter 6 in this book)
See the biblatex manual, sec. 3.8.3., for details.
File format change.
2017-01-21 13:25:17 +00:00
|
|
|
os << escape(cleanupWhitespace(key));
|
2017-01-13 10:53:22 +00:00
|
|
|
else
|
Support for "qualified citation lists"
These are biblatex-specific multicite commands that allow for multiple
pre- and postnotes, as in:
\cites(pre)(post)[pre1][post1]{key1}[pre2][post2]{key2}...
with an optional general pre- and postnote, which applies to the whole
list (like [][] in normal cite commands) and an optional pre- and
postnotes for each item, so that pagination can actually be specified in
multi-cite references, as in:
(cf. Miller 2015, 2; furthermore Smith 2013, 23-23; Jenkins 2012, 103,
also refer to chapter 6 in this book)
See the biblatex manual, sec. 3.8.3., for details.
File format change.
2017-01-21 13:25:17 +00:00
|
|
|
os << cleanupWhitespace(key);
|
2017-01-13 10:53:22 +00:00
|
|
|
return;
|
|
|
|
}
|
2017-01-14 13:44:18 +00:00
|
|
|
vector<CitationStyle> citation_styles = buffer().masterParams().citeStyles();
|
|
|
|
CitationStyle cs = asValidLatexCommand(buffer().masterParams(),
|
|
|
|
getCmdName(), citation_styles);
|
2006-10-19 16:51:30 +00:00
|
|
|
// FIXME UNICODE
|
2017-01-03 12:11:11 +00:00
|
|
|
docstring const cite_str = from_utf8(citationStyleToString(cs, true));
|
2004-10-05 10:11:42 +00:00
|
|
|
|
Support for "qualified citation lists"
These are biblatex-specific multicite commands that allow for multiple
pre- and postnotes, as in:
\cites(pre)(post)[pre1][post1]{key1}[pre2][post2]{key2}...
with an optional general pre- and postnote, which applies to the whole
list (like [][] in normal cite commands) and an optional pre- and
postnotes for each item, so that pagination can actually be specified in
multi-cite references, as in:
(cf. Miller 2015, 2; furthermore Smith 2013, 23-23; Jenkins 2012, 103,
also refer to chapter 6 in this book)
See the biblatex manual, sec. 3.8.3., for details.
File format change.
2017-01-21 13:25:17 +00:00
|
|
|
// check if we have to do a qualified list
|
|
|
|
vector<docstring> keys = getVectorFromString(cleanupWhitespace(key));
|
|
|
|
bool const qualified = cs.hasQualifiedList
|
|
|
|
&& (!getParam("pretextlist").empty()
|
|
|
|
|| !getParam("posttextlist").empty());
|
|
|
|
|
2014-03-22 11:25:25 +00:00
|
|
|
if (runparams.inulemcmd > 0)
|
2009-05-07 10:57:52 +00:00
|
|
|
os << "\\mbox{";
|
|
|
|
|
2004-05-14 15:27:13 +00:00
|
|
|
os << "\\" << cite_str;
|
2004-10-05 10:11:42 +00:00
|
|
|
|
Support for "qualified citation lists"
These are biblatex-specific multicite commands that allow for multiple
pre- and postnotes, as in:
\cites(pre)(post)[pre1][post1]{key1}[pre2][post2]{key2}...
with an optional general pre- and postnote, which applies to the whole
list (like [][] in normal cite commands) and an optional pre- and
postnotes for each item, so that pagination can actually be specified in
multi-cite references, as in:
(cf. Miller 2015, 2; furthermore Smith 2013, 23-23; Jenkins 2012, 103,
also refer to chapter 6 in this book)
See the biblatex manual, sec. 3.8.3., for details.
File format change.
2017-01-21 13:25:17 +00:00
|
|
|
if (qualified)
|
|
|
|
os << "s";
|
|
|
|
|
2018-02-22 06:00:18 +00:00
|
|
|
ParamInfo const & pinfo = findInfo(string());
|
2017-01-30 06:44:55 +00:00
|
|
|
docstring before = params().prepareCommand(runparams, getParam("before"),
|
2018-02-22 06:00:18 +00:00
|
|
|
pinfo["before"].handling());
|
2017-01-30 06:44:55 +00:00
|
|
|
docstring after = params().prepareCommand(runparams, getParam("after"),
|
2018-02-22 06:00:18 +00:00
|
|
|
pinfo["after"].handling());
|
Support for "qualified citation lists"
These are biblatex-specific multicite commands that allow for multiple
pre- and postnotes, as in:
\cites(pre)(post)[pre1][post1]{key1}[pre2][post2]{key2}...
with an optional general pre- and postnote, which applies to the whole
list (like [][] in normal cite commands) and an optional pre- and
postnotes for each item, so that pagination can actually be specified in
multi-cite references, as in:
(cf. Miller 2015, 2; furthermore Smith 2013, 23-23; Jenkins 2012, 103,
also refer to chapter 6 in this book)
See the biblatex manual, sec. 3.8.3., for details.
File format change.
2017-01-21 13:25:17 +00:00
|
|
|
if (!before.empty() && cs.textBefore) {
|
2017-01-22 09:27:06 +00:00
|
|
|
if (qualified)
|
|
|
|
os << '(' << protectArgument(before, '(', ')')
|
|
|
|
<< ")(" << protectArgument(after, '(', ')') << ')';
|
|
|
|
else
|
|
|
|
os << '[' << protectArgument(before) << "]["
|
|
|
|
<< protectArgument(after) << ']';
|
Support for "qualified citation lists"
These are biblatex-specific multicite commands that allow for multiple
pre- and postnotes, as in:
\cites(pre)(post)[pre1][post1]{key1}[pre2][post2]{key2}...
with an optional general pre- and postnote, which applies to the whole
list (like [][] in normal cite commands) and an optional pre- and
postnotes for each item, so that pagination can actually be specified in
multi-cite references, as in:
(cf. Miller 2015, 2; furthermore Smith 2013, 23-23; Jenkins 2012, 103,
also refer to chapter 6 in this book)
See the biblatex manual, sec. 3.8.3., for details.
File format change.
2017-01-21 13:25:17 +00:00
|
|
|
} else if (!after.empty() && cs.textAfter) {
|
2017-01-22 09:27:06 +00:00
|
|
|
if (qualified)
|
|
|
|
os << '(' << protectArgument(after, '(', ')') << ')';
|
|
|
|
else
|
|
|
|
os << '[' << protectArgument(after) << ']';
|
Support for "qualified citation lists"
These are biblatex-specific multicite commands that allow for multiple
pre- and postnotes, as in:
\cites(pre)(post)[pre1][post1]{key1}[pre2][post2]{key2}...
with an optional general pre- and postnote, which applies to the whole
list (like [][] in normal cite commands) and an optional pre- and
postnotes for each item, so that pagination can actually be specified in
multi-cite references, as in:
(cf. Miller 2015, 2; furthermore Smith 2013, 23-23; Jenkins 2012, 103,
also refer to chapter 6 in this book)
See the biblatex manual, sec. 3.8.3., for details.
File format change.
2017-01-21 13:25:17 +00:00
|
|
|
}
|
2004-03-05 14:49:10 +00:00
|
|
|
|
Support for "qualified citation lists"
These are biblatex-specific multicite commands that allow for multiple
pre- and postnotes, as in:
\cites(pre)(post)[pre1][post1]{key1}[pre2][post2]{key2}...
with an optional general pre- and postnote, which applies to the whole
list (like [][] in normal cite commands) and an optional pre- and
postnotes for each item, so that pagination can actually be specified in
multi-cite references, as in:
(cf. Miller 2015, 2; furthermore Smith 2013, 23-23; Jenkins 2012, 103,
also refer to chapter 6 in this book)
See the biblatex manual, sec. 3.8.3., for details.
File format change.
2017-01-21 13:25:17 +00:00
|
|
|
if (!bi.isBibtex(key))
|
2010-02-12 16:08:30 +00:00
|
|
|
// escape chars with bibitems
|
Support for "qualified citation lists"
These are biblatex-specific multicite commands that allow for multiple
pre- and postnotes, as in:
\cites(pre)(post)[pre1][post1]{key1}[pre2][post2]{key2}...
with an optional general pre- and postnote, which applies to the whole
list (like [][] in normal cite commands) and an optional pre- and
postnotes for each item, so that pagination can actually be specified in
multi-cite references, as in:
(cf. Miller 2015, 2; furthermore Smith 2013, 23-23; Jenkins 2012, 103,
also refer to chapter 6 in this book)
See the biblatex manual, sec. 3.8.3., for details.
File format change.
2017-01-21 13:25:17 +00:00
|
|
|
os << '{' << escape(cleanupWhitespace(key)) << '}';
|
|
|
|
else {
|
|
|
|
if (qualified) {
|
2019-08-07 11:00:29 +00:00
|
|
|
QualifiedList pres = getQualifiedLists(getParam("pretextlist"));
|
|
|
|
QualifiedList posts = getQualifiedLists(getParam("posttextlist"));
|
|
|
|
for (docstring const & k : keys) {
|
|
|
|
docstring prenote;
|
|
|
|
QualifiedList::iterator it = pres.begin();
|
|
|
|
for (; it != pres.end() ; ++it) {
|
|
|
|
if ((*it).first == k) {
|
|
|
|
prenote = (*it).second;
|
|
|
|
pres.erase(it);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
docstring bef = params().prepareCommand(runparams, prenote,
|
2018-02-22 06:00:18 +00:00
|
|
|
pinfo["pretextlist"].handling());
|
2019-08-07 11:00:29 +00:00
|
|
|
docstring postnote;
|
|
|
|
QualifiedList::iterator pit = posts.begin();
|
|
|
|
for (; pit != posts.end() ; ++pit) {
|
|
|
|
if ((*pit).first == k) {
|
|
|
|
postnote = (*pit).second;
|
|
|
|
posts.erase(pit);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
docstring aft = params().prepareCommand(runparams, postnote,
|
2018-02-22 06:00:18 +00:00
|
|
|
pinfo["posttextlist"].handling());
|
Support for "qualified citation lists"
These are biblatex-specific multicite commands that allow for multiple
pre- and postnotes, as in:
\cites(pre)(post)[pre1][post1]{key1}[pre2][post2]{key2}...
with an optional general pre- and postnote, which applies to the whole
list (like [][] in normal cite commands) and an optional pre- and
postnotes for each item, so that pagination can actually be specified in
multi-cite references, as in:
(cf. Miller 2015, 2; furthermore Smith 2013, 23-23; Jenkins 2012, 103,
also refer to chapter 6 in this book)
See the biblatex manual, sec. 3.8.3., for details.
File format change.
2017-01-21 13:25:17 +00:00
|
|
|
if (!bef.empty())
|
2017-01-22 09:27:06 +00:00
|
|
|
os << '[' << protectArgument(bef)
|
|
|
|
<< "][" << protectArgument(aft) << ']';
|
Support for "qualified citation lists"
These are biblatex-specific multicite commands that allow for multiple
pre- and postnotes, as in:
\cites(pre)(post)[pre1][post1]{key1}[pre2][post2]{key2}...
with an optional general pre- and postnote, which applies to the whole
list (like [][] in normal cite commands) and an optional pre- and
postnotes for each item, so that pagination can actually be specified in
multi-cite references, as in:
(cf. Miller 2015, 2; furthermore Smith 2013, 23-23; Jenkins 2012, 103,
also refer to chapter 6 in this book)
See the biblatex manual, sec. 3.8.3., for details.
File format change.
2017-01-21 13:25:17 +00:00
|
|
|
else if (!aft.empty())
|
2017-01-22 09:27:06 +00:00
|
|
|
os << '[' << protectArgument(aft) << ']';
|
Support for "qualified citation lists"
These are biblatex-specific multicite commands that allow for multiple
pre- and postnotes, as in:
\cites(pre)(post)[pre1][post1]{key1}[pre2][post2]{key2}...
with an optional general pre- and postnote, which applies to the whole
list (like [][] in normal cite commands) and an optional pre- and
postnotes for each item, so that pagination can actually be specified in
multi-cite references, as in:
(cf. Miller 2015, 2; furthermore Smith 2013, 23-23; Jenkins 2012, 103,
also refer to chapter 6 in this book)
See the biblatex manual, sec. 3.8.3., for details.
File format change.
2017-01-21 13:25:17 +00:00
|
|
|
os << '{' << k << '}';
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
os << '{' << cleanupWhitespace(key) << '}';
|
|
|
|
}
|
2001-07-19 14:12:37 +00:00
|
|
|
|
2009-05-07 10:57:52 +00:00
|
|
|
if (runparams.inulemcmd)
|
|
|
|
os << "}";
|
2001-07-19 14:12:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-10-29 14:48:55 +00:00
|
|
|
string InsetCitation::contextMenuName() const
|
2008-04-28 15:21:55 +00:00
|
|
|
{
|
2011-10-29 14:48:55 +00:00
|
|
|
return "context-citation";
|
2008-04-28 15:21:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|