void Document::writeBibtex ( Library const &lib, std::ostringstream& out, bool const usebraces, bool const utf8) { // BibTeX values cannot be larger than 1000 characters - should make sure of this // We should strip illegal characters from key in a predictable way out << "@" << bib_.getType() << "{" << key_ << ",\n"; BibData::ExtrasMap extras = bib_.getExtras (); BibData::ExtrasMap::iterator it = extras.begin (); BibData::ExtrasMap::iterator const end = extras.end (); for (; it != end; ++it) { // Exceptions to usebraces are editor and author because we // don't want "Foo, B.B. and John Bar" to be literal writeBibKey ( out, (*it).first, (*it).second, ((*it).first.lowercase () != "editor") && usebraces, utf8); } // Ideally should know what's a list of human names and what's an // institution name be doing something different for non-human-name authors? writeBibKey (out, "author", bib_.getAuthors(), false, utf8); writeBibKey (out, "title", bib_.getTitle(), usebraces, utf8); writeBibKey (out, "journal", bib_.getJournal(), usebraces, utf8); writeBibKey (out, "volume", bib_.getVolume(), false, utf8); writeBibKey (out, "number", bib_.getIssue(), false, utf8); writeBibKey (out, "pages", bib_.getPages(), false, utf8); writeBibKey (out, "year", bib_.getYear(), false, utf8); writeBibKey (out, "doi", bib_.getDoi(), false, utf8); if (tagUids_.size () > 0) { out << "\ttags = \""; std::vector<int>::iterator tagit = tagUids_.begin (); std::vector<int>::iterator const tagend = tagUids_.end (); for (; tagit != tagend; ++tagit) { if (tagit != tagUids_.begin ()) out << ", "; out << lib.getTagList()->getName(*tagit); } out << "\"\n"; } out << "}\n\n"; }
/** * Temporarily duplicating functionality in printBibtex and * writeBibtex -- the difference is that writeBibtex requires a * Library reference in order to resolve tag uids to names. * In order to be usable from PythonDocument printBibtex just * doesn't bother printing tags at all. * * This will get fixed when the ill-conceived tag ID system is * replaced with lists of strings */ Glib::ustring Document::printBibtex ( bool const useBraces, bool const utf8) { std::ostringstream out; // BibTeX values cannot be larger than 1000 characters - should make sure of this // We should strip illegal characters from key in a predictable way out << "@" << bib_.getType() << "{" << key_ << ",\n"; BibData::ExtrasMap extras = bib_.getExtras (); BibData::ExtrasMap::iterator it = extras.begin (); BibData::ExtrasMap::iterator const end = extras.end (); for (; it != end; ++it) { // Exceptions to useBraces are editor and author because we // don't want "Foo, B.B. and John Bar" to be literal writeBibKey ( out, (*it).first, (*it).second, ((*it).first.lowercase () != "editor") && useBraces, utf8); } // Ideally should know what's a list of human names and what's an // institution name be doing something different for non-human-name authors? writeBibKey (out, "author", bib_.getAuthors(), false, utf8); writeBibKey (out, "title", bib_.getTitle(), useBraces, utf8); writeBibKey (out, "journal", bib_.getJournal(), useBraces, utf8); writeBibKey (out, "volume", bib_.getVolume(), false, utf8); writeBibKey (out, "number", bib_.getIssue(), false, utf8); writeBibKey (out, "pages", bib_.getPages(), false, utf8); writeBibKey (out, "year", bib_.getYear(), false, utf8); writeBibKey (out, "doi", bib_.getDoi(), false, utf8); out << "}\n\n"; return out.str(); }