3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Angus Leeming
11 * Full author contact details are available in file CREDITS.
16 #include "BiblioInfo.h"
18 #include "BufferParams.h"
19 #include "buffer_funcs.h"
21 #include "InsetIterator.h"
23 #include "output_xhtml.h"
24 #include "Paragraph.h"
25 #include "TextClass.h"
26 #include "TocBackend.h"
28 #include "support/convert.h"
29 #include "support/debug.h"
30 #include "support/docstream.h"
31 #include "support/gettext.h"
32 #include "support/lassert.h"
33 #include "support/lstrings.h"
34 #include "support/regex.h"
35 #include "support/textutils.h"
40 using namespace lyx::support;
47 // gets the "family name" from an author-type string
48 docstring familyName(docstring const & name)
53 // first we look for a comma, and take the last name to be everything
54 // preceding the right-most one, so that we also get the "jr" part.
55 docstring::size_type idx = name.rfind(',');
56 if (idx != docstring::npos)
57 return ltrim(name.substr(0, idx));
59 // OK, so now we want to look for the last name. We're going to
60 // include the "von" part. This isn't perfect.
61 // Split on spaces, to get various tokens.
62 vector<docstring> pieces = getVectorFromString(name, from_ascii(" "));
63 // If we only get two, assume the last one is the last name
64 if (pieces.size() <= 2)
67 // Now we look for the first token that begins with a lower case letter.
68 vector<docstring>::const_iterator it = pieces.begin();
69 vector<docstring>::const_iterator en = pieces.end();
70 for (; it != en; ++it) {
73 char_type const c = (*it)[0];
78 if (it == en) // we never found a "von"
81 // reconstruct what we need to return
84 for (; it != en; ++it) {
95 // converts a string containing LaTeX commands into unicode
97 docstring convertLaTeXCommands(docstring const & str)
102 bool scanning_cmd = false;
103 bool scanning_math = false;
104 bool escaped = false; // used to catch \$, etc.
105 while (!val.empty()) {
106 char_type const ch = val[0];
108 // if we're scanning math, we output everything until we
109 // find an unescaped $, at which point we break out.
116 scanning_math = false;
122 // if we're scanning a command name, then we just
123 // discard characters until we hit something that
126 if (isAlphaASCII(ch)) {
131 // so we're done with this command.
132 // now we fall through and check this character.
133 scanning_cmd = false;
136 // was the last character a \? If so, then this is something like:
137 // \\ or \$, so we'll just output it. That's probably not always right...
139 // exception: output \, as THIN SPACE
141 ret.push_back(0x2009);
152 scanning_math = true;
156 // we just ignore braces
157 if (ch == '{' || ch == '}') {
162 // we're going to check things that look like commands, so if
163 // this doesn't, just output it.
170 // ok, could be a command of some sort
171 // let's see if it corresponds to some unicode
172 // unicodesymbols has things in the form: \"{u},
173 // whereas we may see things like: \"u. So we'll
174 // look for that and change it, if necessary.
175 // FIXME: This is a sort of mini-tex2lyx.
176 // Use the real tex2lyx instead!
177 static lyx::regex const reg("^\\\\\\W\\w");
178 if (lyx::regex_search(to_utf8(val), reg)) {
179 val.insert(3, from_ascii("}"));
180 val.insert(2, from_ascii("{"));
184 docstring const cnvtd = Encodings::fromLaTeXCommand(val,
185 Encodings::TEXT_CMD, termination, rem);
186 if (!cnvtd.empty()) {
187 // it did, so we'll take that bit and proceed with what's left
192 // it's a command of some sort
201 // Escape '<' and '>' and remove richtext markers (e.g. {!this is richtext!}) from a string.
202 docstring processRichtext(docstring const & str, bool richtext)
207 bool scanning_rich = false;
208 while (!val.empty()) {
209 char_type const ch = val[0];
210 if (ch == '{' && val.size() > 1 && val[1] == '!') {
211 // beginning of rich text
212 scanning_rich = true;
216 if (scanning_rich && ch == '!' && val.size() > 1 && val[1] == '}') {
218 scanning_rich = false;
226 // we need to escape '<' and '>'
234 } else if (!scanning_rich /* && !richtext */)
236 // else the character is discarded, which will happen only if
237 // richtext == false and we are scanning rich text
246 //////////////////////////////////////////////////////////////////////
250 //////////////////////////////////////////////////////////////////////
252 BibTeXInfo::BibTeXInfo(docstring const & key, docstring const & type)
253 : is_bibtex_(true), bib_key_(key), entry_type_(type), info_(),
258 docstring const BibTeXInfo::getAbbreviatedAuthor(bool jurabib_style) const
261 docstring const opt = label();
266 docstring const remainder = trim(split(opt, authors, '('));
267 if (remainder.empty())
268 // in this case, we didn't find a "(",
269 // so we don't have author (year)
274 docstring author = convertLaTeXCommands(operator[]("author"));
275 if (author.empty()) {
276 author = convertLaTeXCommands(operator[]("editor"));
281 // FIXME Move this to a separate routine that can
282 // be called from elsewhere.
284 // OK, we've got some names. Let's format them.
285 // Try to split the author list on " and "
286 vector<docstring> const authors =
287 getVectorFromString(author, from_ascii(" and "));
289 if (jurabib_style && (authors.size() == 2 || authors.size() == 3)) {
290 docstring shortauthor = familyName(authors[0])
291 + "/" + familyName(authors[1]);
292 if (authors.size() == 3)
293 shortauthor += "/" + familyName(authors[2]);
297 if (authors.size() == 2 && authors[1] != "others")
298 return bformat(from_ascii("%1$s and %2$s"),
299 familyName(authors[0]), familyName(authors[1]));
301 if (authors.size() >= 2)
302 return bformat(from_ascii("%1$s et al."),
303 familyName(authors[0]));
305 return familyName(authors[0]);
309 docstring const BibTeXInfo::getAbbreviatedAuthor(Buffer const & buf, bool jurabib_style) const
311 docstring const author = getAbbreviatedAuthor(jurabib_style);
314 vector<docstring> const authors = getVectorFromString(author, from_ascii(" and "));
315 if (authors.size() == 2)
316 return bformat(buf.B_("%1$s and %2$s"), authors[0], authors[1]);
317 docstring::size_type const idx = author.rfind(from_ascii(" et al."));
318 if (idx != docstring::npos)
319 return bformat(buf.B_("%1$s et al."), author.substr(0, idx));
324 docstring const BibTeXInfo::getYear() const
327 return operator[]("year");
329 docstring const opt = label();
334 docstring tmp = split(opt, authors, '(');
336 // we don't have author (year)
339 tmp = split(tmp, year, ')');
344 docstring const BibTeXInfo::getXRef() const
348 return operator[]("crossref");
354 string parseOptions(string const & format, string & optkey,
355 string & ifpart, string & elsepart);
357 // Calls parseOptions to deal with an embedded option, such as:
358 // {%number%[[, no.~%number%]]}
359 // which must appear at the start of format. ifelsepart gets the
360 // whole of the option, and we return what's left after the option.
361 // we return format if there is an error.
362 string parseEmbeddedOption(string const & format, string & ifelsepart)
364 LASSERT(format[0] == '{' && format[1] == '%', return format);
368 string const rest = parseOptions(format, optkey, ifpart, elsepart);
369 if (format == rest) { // parse error
370 LYXERR0("ERROR! Couldn't parse `" << format <<"'.");
373 LASSERT(rest.size() <= format.size(),
374 { ifelsepart = ""; return format; });
375 ifelsepart = format.substr(0, format.size() - rest.size());
380 // Gets a "clause" from a format string, where the clause is
381 // delimited by '[[' and ']]'. Returns what is left after the
382 // clause is removed, and returns format if there is an error.
383 string getClause(string const & format, string & clause)
388 // we'll remove characters from the front of fmt as we
390 while (!fmt.empty()) {
391 if (fmt[0] == ']' && fmt.size() > 1 && fmt[1] == ']') {
396 // check for an embedded option
397 if (fmt[0] == '{' && fmt.size() > 1 && fmt[1] == '%') {
399 string const rest = parseEmbeddedOption(fmt, part);
401 LYXERR0("ERROR! Couldn't parse embedded option in `" << format <<"'.");
406 } else { // it's just a normal character
415 // parse an options string, which must appear at the start of the
416 // format parameter. puts the parsed bits in optkey, ifpart, and
417 // elsepart and returns what's left after the option is removed.
418 // if there's an error, it returns format itself.
419 string parseOptions(string const & format, string & optkey,
420 string & ifpart, string & elsepart)
422 LASSERT(format[0] == '{' && format[1] == '%', return format);
424 string fmt = format.substr(2);
425 size_t pos = fmt.find('%'); // end of key
426 if (pos == string::npos) {
427 LYXERR0("Error parsing `" << format <<"'. Can't find end of key.");
430 optkey = fmt.substr(0,pos);
431 fmt = fmt.substr(pos + 1);
432 // [[format]] should be next
433 if (fmt[0] != '[' || fmt[1] != '[') {
434 LYXERR0("Error parsing `" << format <<"'. Can't find '[[' after key.");
439 fmt = getClause(curfmt, ifpart);
441 LYXERR0("Error parsing `" << format <<"'. Couldn't get if clause.");
445 if (fmt[0] == '}') // we're done, no else clause
446 return fmt.substr(1);
448 // else part should follow
449 if (fmt[0] != '[' || fmt[1] != '[') {
450 LYXERR0("Error parsing `" << format <<"'. Can't find else clause.");
455 fmt = getClause(curfmt, elsepart);
457 if (fmt == curfmt || fmt[0] != '}') {
458 LYXERR0("Error parsing `" << format <<"'. Can't find end of option.");
461 return fmt.substr(1);
468 docstring BibTeXInfo::expandFormat(string const & format,
469 BibTeXInfo const * const xref, int & counter, Buffer const & buf,
470 docstring before, docstring after, docstring dialog, bool next) const
472 // incorrect use of macros could put us in an infinite loop
473 static int max_passes = 5000;
474 docstring ret; // return value
476 bool scanning_key = false;
477 bool scanning_rich = false;
479 CiteEngineType const engine_type = buf.params().citeEngineType();
481 // we'll remove characters from the front of fmt as we
483 while (!fmt.empty()) {
484 if (counter++ > max_passes) {
485 LYXERR0("Recursion limit reached while parsing `"
490 char_type thischar = fmt[0];
491 if (thischar == '%') {
492 // beginning or end of key
495 scanning_key = false;
496 // so we replace the key with its value, which may be empty
500 buf.params().documentClass().getCiteMacro(engine_type, key);
501 fmt = val + fmt.substr(1);
503 } else if (key[0] == '_') {
504 // a translatable bit
506 buf.params().documentClass().getCiteMacro(engine_type, key);
507 docstring const trans =
508 translateIfPossible(from_utf8(val), buf.params().language->code());
511 docstring const val =
512 getValueForKey(key, buf, before, after, dialog, xref);
514 ret += from_ascii("{!<span class=\"bib-" + key + "\">!}");
517 ret += from_ascii("{!</span>!}");
525 else if (thischar == '{') {
526 // beginning of option?
528 LYXERR0("ERROR: Found `{' when scanning key in `" << format << "'.");
531 if (fmt.size() > 1) {
533 // it is the beginning of an optional format
537 string const newfmt =
538 parseOptions(fmt, optkey, ifpart, elsepart);
539 if (newfmt == fmt) // parse error
542 docstring const val =
543 getValueForKey(optkey, buf, before, after, dialog, xref);
544 if (optkey == "next" && next)
545 ret += from_utf8(ifpart); // without expansion
546 else if (!val.empty())
547 ret += expandFormat(ifpart, xref, counter, buf,
548 before, after, dialog, next);
549 else if (!elsepart.empty())
550 ret += expandFormat(elsepart, xref, counter, buf,
551 before, after, dialog, next);
552 // fmt will have been shortened for us already
556 // beginning of rich text
557 scanning_rich = true;
559 ret += from_ascii("{!");
563 // we are here if '{' was not followed by % or !.
564 // So it's just a character.
567 else if (scanning_rich && thischar == '!'
568 && fmt.size() > 1 && fmt[1] == '}') {
570 scanning_rich = false;
572 ret += from_ascii("!}");
575 else if (scanning_key)
576 key += char(thischar);
582 LYXERR0("Never found end of key in `" << format << "'!");
586 LYXERR0("Never found end of rich text in `" << format << "'!");
593 docstring const & BibTeXInfo::getInfo(BibTeXInfo const * const xref,
594 Buffer const & buf, bool richtext) const
596 if (!richtext && !info_.empty())
598 if (richtext && !info_richtext_.empty())
599 return info_richtext_;
602 BibTeXInfo::const_iterator it = find(from_ascii("ref"));
607 CiteEngineType const engine_type = buf.params().citeEngineType();
608 DocumentClass const & dc = buf.params().documentClass();
609 string const & format = dc.getCiteFormat(engine_type, to_utf8(entry_type_));
611 info_ = expandFormat(format, xref, counter, buf,
612 docstring(), docstring(), docstring(), false);
614 if (!info_.empty()) {
615 info_richtext_ = convertLaTeXCommands(processRichtext(info_, true));
616 info_ = convertLaTeXCommands(processRichtext(info_, false));
618 return info_richtext_;
624 docstring const BibTeXInfo::getLabel(BibTeXInfo const * const xref,
625 Buffer const & buf, string const & format, bool richtext,
626 docstring before, docstring after, docstring dialog, bool next) const
631 loclabel = expandFormat(format, xref, counter, buf,
632 before, after, dialog, next);
634 if (!loclabel.empty() && !next) {
635 loclabel = processRichtext(loclabel, richtext);
636 loclabel = convertLaTeXCommands(loclabel);
642 docstring const & BibTeXInfo::operator[](docstring const & field) const
644 BibTeXInfo::const_iterator it = find(field);
647 static docstring const empty_value = docstring();
652 docstring const & BibTeXInfo::operator[](string const & field) const
654 return operator[](from_ascii(field));
658 docstring BibTeXInfo::getValueForKey(string const & oldkey, Buffer const & buf,
659 docstring const & before, docstring const & after, docstring const & dialog,
660 BibTeXInfo const * const xref) const
663 bool cleanit = false;
664 if (prefixIs(oldkey, "clean:")) {
665 key = oldkey.substr(6);
669 docstring ret = operator[](key);
670 if (ret.empty() && xref)
674 // FIXME: dialog, textbefore and textafter have nothing to do with this
677 else if (key == "entrytype")
679 else if (key == "key")
681 else if (key == "label")
683 else if (key == "abbrvauthor")
684 // Special key to provide abbreviated author names.
685 ret = getAbbreviatedAuthor(buf, false);
686 else if (key == "shortauthor")
687 // When shortauthor is not defined, jurabib automatically
688 // provides jurabib-style abbreviated author names. We do
690 ret = getAbbreviatedAuthor(buf, true);
691 else if (key == "shorttitle") {
692 // When shorttitle is not defined, jurabib uses for `article'
693 // and `periodical' entries the form `journal volume [year]'
694 // and for other types of entries it uses the `title' field.
695 if (entry_type_ == "article" || entry_type_ == "periodical")
696 ret = operator[]("journal") + " " + operator[]("volume")
697 + " [" + operator[]("year") + "]";
699 ret = operator[]("title");
700 } else if (key == "bibentry") {
701 // Special key to provide the full bibliography entry: see getInfo()
702 CiteEngineType const engine_type = buf.params().citeEngineType();
703 DocumentClass const & dc = buf.params().documentClass();
704 string const & format = dc.getCiteFormat(engine_type, to_utf8(entry_type_));
706 ret = expandFormat(format, xref, counter, buf,
707 docstring(), docstring(), docstring(), false);
708 } else if (key == "textbefore")
710 else if (key == "textafter")
712 else if (key == "year")
716 return html::cleanAttr(ret);
722 //////////////////////////////////////////////////////////////////////
726 //////////////////////////////////////////////////////////////////////
730 // A functor for use with sort, leading to case insensitive sorting
731 class compareNoCase: public binary_function<docstring, docstring, bool>
734 bool operator()(docstring const & s1, docstring const & s2) const {
735 return compare_no_case(s1, s2) < 0;
742 vector<docstring> const BiblioInfo::getKeys() const
744 vector<docstring> bibkeys;
745 BiblioInfo::const_iterator it = begin();
746 for (; it != end(); ++it)
747 bibkeys.push_back(it->first);
748 sort(bibkeys.begin(), bibkeys.end(), compareNoCase());
753 vector<docstring> const BiblioInfo::getFields() const
755 vector<docstring> bibfields;
756 set<docstring>::const_iterator it = field_names_.begin();
757 set<docstring>::const_iterator end = field_names_.end();
758 for (; it != end; ++it)
759 bibfields.push_back(*it);
760 sort(bibfields.begin(), bibfields.end());
765 vector<docstring> const BiblioInfo::getEntries() const
767 vector<docstring> bibentries;
768 set<docstring>::const_iterator it = entry_types_.begin();
769 set<docstring>::const_iterator end = entry_types_.end();
770 for (; it != end; ++it)
771 bibentries.push_back(*it);
772 sort(bibentries.begin(), bibentries.end());
777 docstring const BiblioInfo::getAbbreviatedAuthor(docstring const & key, Buffer const & buf) const
779 BiblioInfo::const_iterator it = find(key);
782 BibTeXInfo const & data = it->second;
783 return data.getAbbreviatedAuthor(buf, false);
787 docstring const BiblioInfo::getCiteNumber(docstring const & key) const
789 BiblioInfo::const_iterator it = find(key);
792 BibTeXInfo const & data = it->second;
793 return data.citeNumber();
797 docstring const BiblioInfo::getYear(docstring const & key, bool use_modifier) const
799 BiblioInfo::const_iterator it = find(key);
802 BibTeXInfo const & data = it->second;
803 docstring year = data.getYear();
805 // let's try the crossref
806 docstring const xref = data.getXRef();
810 BiblioInfo::const_iterator const xrefit = find(xref);
814 BibTeXInfo const & xref_data = xrefit->second;
815 year = xref_data.getYear();
817 if (use_modifier && data.modifier() != 0)
818 year += data.modifier();
823 docstring const BiblioInfo::getYear(docstring const & key, Buffer const & buf, bool use_modifier) const
825 docstring const year = getYear(key, use_modifier);
827 return buf.B_("No year");
832 docstring const BiblioInfo::getInfo(docstring const & key,
833 Buffer const & buf, bool richtext) const
835 BiblioInfo::const_iterator it = find(key);
837 return docstring(_("Bibliography entry not found!"));
838 BibTeXInfo const & data = it->second;
839 BibTeXInfo const * xrefptr = 0;
840 docstring const xref = data.getXRef();
842 BiblioInfo::const_iterator const xrefit = find(xref);
844 xrefptr = &(xrefit->second);
846 return data.getInfo(xrefptr, buf, richtext);
850 docstring const BiblioInfo::getLabel(vector<docstring> const & keys,
851 Buffer const & buf, string const & style, bool richtext,
852 docstring const & before, docstring const & after, docstring const & dialog) const
854 CiteEngineType const engine_type = buf.params().citeEngineType();
855 DocumentClass const & dc = buf.params().documentClass();
856 string const & format = dc.getCiteFormat(engine_type, style, "cite");
857 docstring ret = from_utf8(format);
858 vector<docstring>::const_iterator key = keys.begin();
859 vector<docstring>::const_iterator ken = keys.end();
860 for (; key != ken; ++key) {
861 BiblioInfo::const_iterator it = find(*key);
862 BibTeXInfo empty_data;
863 empty_data.key(*key);
864 BibTeXInfo & data = empty_data;
865 BibTeXInfo const * xrefptr = 0;
868 docstring const xref = data.getXRef();
870 BiblioInfo::const_iterator const xrefit = find(xref);
872 xrefptr = &(xrefit->second);
875 ret = data.getLabel(xrefptr, buf, to_utf8(ret), richtext,
876 before, after, dialog, key+1 != ken);
882 bool BiblioInfo::isBibtex(docstring const & key) const
884 BiblioInfo::const_iterator it = find(key);
887 return it->second.isBibTeX();
891 vector<docstring> const BiblioInfo::getCiteStrings(
892 vector<docstring> const & keys, vector<CitationStyle> const & styles,
893 Buffer const & buf, bool richtext, docstring const & before,
894 docstring const & after, docstring const & dialog) const
897 return vector<docstring>();
900 vector<docstring> vec(styles.size());
901 for (size_t i = 0; i != vec.size(); ++i) {
902 style = styles[i].cmd;
903 vec[i] = getLabel(keys, buf, style, richtext, before, after, dialog);
910 void BiblioInfo::mergeBiblioInfo(BiblioInfo const & info)
912 bimap_.insert(info.begin(), info.end());
913 field_names_.insert(info.field_names_.begin(), info.field_names_.end());
914 entry_types_.insert(info.entry_types_.begin(), info.entry_types_.end());
920 // used in xhtml to sort a list of BibTeXInfo objects
921 bool lSorter(BibTeXInfo const * lhs, BibTeXInfo const * rhs)
923 docstring const lauth = lhs->getAbbreviatedAuthor();
924 docstring const rauth = rhs->getAbbreviatedAuthor();
925 docstring const lyear = lhs->getYear();
926 docstring const ryear = rhs->getYear();
927 docstring const ltitl = lhs->operator[]("title");
928 docstring const rtitl = rhs->operator[]("title");
929 return (lauth < rauth)
930 || (lauth == rauth && lyear < ryear)
931 || (lauth == rauth && lyear == ryear && ltitl < rtitl);
937 void BiblioInfo::collectCitedEntries(Buffer const & buf)
939 cited_entries_.clear();
940 // We are going to collect all the citation keys used in the document,
941 // getting them from the TOC.
942 // FIXME We may want to collect these differently, in the first case,
943 // so that we might have them in order of appearance.
944 set<docstring> citekeys;
945 Toc const & toc = buf.tocBackend().toc("citation");
946 Toc::const_iterator it = toc.begin();
947 Toc::const_iterator const en = toc.end();
948 for (; it != en; ++it) {
949 if (it->str().empty())
951 vector<docstring> const keys = getVectorFromString(it->str());
952 citekeys.insert(keys.begin(), keys.end());
954 if (citekeys.empty())
957 // We have a set of the keys used in this document.
958 // We will now convert it to a list of the BibTeXInfo objects used in
960 vector<BibTeXInfo const *> bi;
961 set<docstring>::const_iterator cit = citekeys.begin();
962 set<docstring>::const_iterator const cen = citekeys.end();
963 for (; cit != cen; ++cit) {
964 BiblioInfo::const_iterator const bt = find(*cit);
965 if (bt == end() || !bt->second.isBibTeX())
967 bi.push_back(&(bt->second));
970 sort(bi.begin(), bi.end(), lSorter);
972 // Now we can write the sorted keys
973 vector<BibTeXInfo const *>::const_iterator bit = bi.begin();
974 vector<BibTeXInfo const *>::const_iterator ben = bi.end();
975 for (; bit != ben; ++bit)
976 cited_entries_.push_back((*bit)->key());
980 void BiblioInfo::makeCitationLabels(Buffer const & buf)
982 collectCitedEntries(buf);
983 CiteEngineType const engine_type = buf.params().citeEngineType();
984 bool const numbers = (engine_type == ENGINE_TYPE_NUMERICAL);
988 // used to remember the last one we saw
989 // we'll be comparing entries to see if we need to add
990 // modifiers, like "1984a"
991 map<docstring, BibTeXInfo>::iterator last;
993 vector<docstring>::const_iterator it = cited_entries_.begin();
994 vector<docstring>::const_iterator const en = cited_entries_.end();
995 for (; it != en; ++it) {
996 map<docstring, BibTeXInfo>::iterator const biit = bimap_.find(*it);
997 // this shouldn't happen, but...
998 if (biit == bimap_.end())
999 // ...fail gracefully, anyway.
1001 BibTeXInfo & entry = biit->second;
1003 docstring const num = convert<docstring>(++keynumber);
1004 entry.setCiteNumber(num);
1006 if (it != cited_entries_.begin()
1007 && entry.getAbbreviatedAuthor() == last->second.getAbbreviatedAuthor()
1008 // we access the year via getYear() so as to get it from the xref,
1009 // if we need to do so
1010 && getYear(entry.key()) == getYear(last->second.key())) {
1011 if (modifier == 0) {
1012 // so the last one should have been 'a'
1013 last->second.setModifier('a');
1015 } else if (modifier == 'z')
1022 entry.setModifier(modifier);
1023 // remember the last one
1028 it = cited_entries_.begin();
1029 for (; it != en; ++it) {
1030 map<docstring, BibTeXInfo>::iterator const biit = bimap_.find(*it);
1031 // this shouldn't happen, but...
1032 if (biit == bimap_.end())
1033 // ...fail gracefully, anyway.
1035 BibTeXInfo & entry = biit->second;
1037 entry.label(entry.citeNumber());
1039 docstring const auth = entry.getAbbreviatedAuthor(buf, false);
1040 // we do it this way so as to access the xref, if necessary
1041 // note that this also gives us the modifier
1042 docstring const year = getYear(*it, buf, true);
1043 if (!auth.empty() && !year.empty())
1044 entry.label(auth + ' ' + year);
1046 entry.label(entry.key());
1052 //////////////////////////////////////////////////////////////////////
1056 //////////////////////////////////////////////////////////////////////
1059 CitationStyle citationStyleFromString(string const & command)
1062 if (command.empty())
1065 string cmd = command;
1066 if (cmd[0] == 'C') {
1067 cs.forceUpperCase = true;
1071 size_t const n = cmd.size() - 1;
1072 if (cmd[n] == '*') {
1073 cs.fullAuthorList = true;
1074 cmd = cmd.substr(0, n);
1082 string citationStyleToString(const CitationStyle & cs)
1084 string cmd = cs.cmd;
1085 if (cs.forceUpperCase)
1087 if (cs.fullAuthorList)