}
+docstring BibTeXInfo::getValueForKey(string const & key,
+ BibTeXInfo const * const xref) const
+{
+ docstring const ret = operator[](key);
+ if (!ret.empty() or !xref)
+ return ret;
+ return (*xref)[key];
+}
+
+
docstring familyName(docstring const & name)
{
if (name.empty())
}
+docstring const BibTeXInfo::getXRef() const
+{
+ if (!is_bibtex_)
+ return docstring();
+ return operator[]("crossref");
+}
+
+
namespace {
docstring convertLaTeXCommands(docstring const & str)
} // anon namespace
-docstring const BibTeXInfo::getInfo() const
+docstring const BibTeXInfo::getInfo(BibTeXInfo const * const xref) const
{
if (!info_.empty())
return info_;
// field to customize the output based upon entry type.
// Search for all possible "required" fields
- docstring author = operator[]("author");
+ docstring author = getValueForKey("author", xref);
if (author.empty())
- author = operator[]("editor");
+ author = getValueForKey("editor", xref);
- docstring year = operator[]("year");
- docstring title = operator[]("title");
- docstring docLoc = operator[]("pages");
+ docstring year = getValueForKey("year", xref);
+ docstring title = getValueForKey("title", xref);
+ docstring docLoc = getValueForKey("pages", xref);
if (docLoc.empty()) {
- docLoc = operator[]("chapter");
+ docLoc = getValueForKey("chapter", xref);
if (!docLoc.empty())
docLoc = from_ascii("Ch. ") + docLoc;
} else {
docLoc = from_ascii("pp. ") + docLoc;
}
- docstring media = operator[]("journal");
+ docstring media = getValueForKey("journal", xref);
if (media.empty()) {
- media = operator[]("publisher");
+ media = getValueForKey("publisher", xref);
if (media.empty()) {
- media = operator[]("school");
+ media = getValueForKey("school", xref);
if (media.empty())
- media = operator[]("institution");
+ media = getValueForKey("institution");
}
}
- docstring volume = operator[]("volume");
+ docstring volume = getValueForKey("volume", xref);
odocstringstream result;
if (!author.empty())
if (!media.empty())
result << ", " << media;
if (!year.empty())
- result << ", " << year;
+ result << " (" << year << ")";
if (!docLoc.empty())
result << ", " << docLoc;
if (it == end())
return docstring();
BibTeXInfo const & data = it->second;
+ docstring year = data.getYear();
+ if (!year.empty())
+ return year;
+ // let's try the crossref
+ docstring const xref = data.getXRef();
+ if (xref.empty())
+ return year; // no luck
+ BiblioInfo::const_iterator const xrefit = find(xref);
+ if (xrefit == end())
+ return year; // no luck again
+ BibTeXInfo const & xref_data = xrefit->second;
+ return xref_data.getYear();
return data.getYear();
}
if (it == end())
return docstring();
BibTeXInfo const & data = it->second;
- return data.getInfo();
+ BibTeXInfo const * xrefptr = 0;
+ docstring const xref = data.getXRef();
+ if (!xref.empty()) {
+ BiblioInfo::const_iterator const xrefit = find(xref);
+ if (xrefit != end())
+ xrefptr = &(xrefit->second);
+ }
+ return data.getInfo(xrefptr);
}
docstring const getAbbreviatedAuthor() const;
///
docstring const getYear() const;
+ ///
+ docstring const getXRef() const;
/// \return formatted BibTeX data suitable for framing.
- docstring const getInfo() const;
+ /// \param pointer to crossref information
+ docstring const getInfo(BibTeXInfo const * const xref = 0) const;
///
int count(docstring const & f) const { return bimap_.count(f); }
///
///
docstring entryType() const { return entry_type_; }
private:
+ /// like operator[], except it will also check the given xref
+ docstring getValueForKey(std::string const & key,
+ BibTeXInfo const * const xref = 0) const;
/// true if from BibTeX; false if from bibliography environment
bool is_bibtex_;
/// the BibTeX key for this entry
/// \return the short form of an authorlist
docstring const getAbbreviatedAuthor(docstring const & key) const;
/// \return the year from the bibtex data record
+ /// Note that this will get the year from the crossref if it's
+ /// not present in the record itself
docstring const getYear(docstring const & key) const;
/// \return formatted BibTeX data associated with a given key.
/// Empty if no info exists.
+ /// Note that this will retrieve data from the crossref as needed.
docstring const getInfo(docstring const & key) const;
/**
* "Translates" the available Citation Styles into strings for a given key,