+ docstring before_str;
+ if (!before.empty()) {
+ // In CITET and CITEALT mode, the "before" string is
+ // attached to the label associated with each and every key.
+ // In CITEP, CITEALP and CITEYEARPAR mode, it is attached
+ // to the front of the whole only.
+ // In other modes, it is not used at all.
+ if (cite_type == "citet" ||
+ cite_type == "citealt" ||
+ cite_type == "citep" ||
+ cite_type == "citealp" ||
+ cite_type == "citeyearpar")
+ before_str = before + ' ';
+ // In CITE (jurabib), the "before" string is used to attach
+ // the annotator (of legal texts) to the author(s) of the
+ // first reference.
+ else if (cite_type == "cite")
+ before_str = '/' + before;
+ }
+
+ docstring after_str;
+ if (!after.empty()) {
+ // The "after" key is appended only to the end of the whole.
+ after_str = ", " + after;
+ }
+
+ // One day, these might be tunable (as they are in BibTeX).
+ char const op = '('; // opening parenthesis.
+ char const cp = ')'; // closing parenthesis.
+ // puctuation mark separating citation entries.
+ char const * const sep = ";";
+
+ docstring const op_str(' ' + docstring(1, op));
+ docstring const cp_str(docstring(1, cp) + ' ');
+ docstring const sep_str(from_ascii(sep) + ' ');
+
+ docstring label;
+ vector<string> keys = getVectorFromString(keyList);
+ vector<string>::const_iterator it = keys.begin();
+ vector<string>::const_iterator end = keys.end();
+ for (; it != end; ++it) {
+ // get the bibdata corresponding to the key
+ docstring const author(biblio::getAbbreviatedAuthor(infomap, *it));
+ docstring const year(biblio::getYear(infomap, *it));
+
+ // Something isn't right. Fail safely.
+ if (author.empty() || year.empty())
+ return docstring();
+
+ // authors1/<before>; ... ;
+ // authors_last, <after>
+ if (cite_type == "cite" && engine == biblio::ENGINE_JURABIB) {
+ if (it == keys.begin())
+ label += author + before_str + sep_str;
+ else
+ label += author + sep_str;
+
+ // (authors1 (<before> year); ... ;
+ // authors_last (<before> year, <after>)
+ } else if (cite_type == "citet") {
+ switch (engine) {
+ case biblio::ENGINE_NATBIB_AUTHORYEAR:
+ label += author + op_str + before_str +
+ year + cp + sep_str;
+ break;
+ case biblio::ENGINE_NATBIB_NUMERICAL:
+ // FIXME UNICODE
+ label += author + op_str + before_str +
+ '#' + from_utf8(*it) + cp + sep_str;
+ break;
+ case biblio::ENGINE_JURABIB:
+ label += before_str + author + op_str +
+ year + cp + sep_str;
+ break;
+ case biblio::ENGINE_BASIC:
+ break;
+ }
+
+ // author, year; author, year; ...
+ } else if (cite_type == "citep" ||
+ cite_type == "citealp") {
+ if (engine == biblio::ENGINE_NATBIB_NUMERICAL) {
+ // FIXME UNICODE
+ label += from_utf8(*it) + sep_str;
+ } else {
+ label += author + ", " + year + sep_str;
+ }
+
+ // (authors1 <before> year;
+ // authors_last <before> year, <after>)
+ } else if (cite_type == "citealt") {
+ switch (engine) {
+ case biblio::ENGINE_NATBIB_AUTHORYEAR:
+ label += author + ' ' + before_str +
+ year + sep_str;
+ break;
+ case biblio::ENGINE_NATBIB_NUMERICAL:
+ // FIXME UNICODE
+ label += author + ' ' + before_str +
+ '#' + from_utf8(*it) + sep_str;
+ break;
+ case biblio::ENGINE_JURABIB:
+ label += before_str + author + ' ' +
+ year + sep_str;
+ break;
+ case biblio::ENGINE_BASIC: