2 * \file InsetBibtex.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Alejandro Aguilar Sierra
7 * \author Richard Heck (BibTeX parser improvements)
8 * \author Jürgen Spitzmüller
10 * Full author contact details are available in file CREDITS.
15 #include "InsetBibtex.h"
17 #include "BiblioInfo.h"
19 #include "BufferParams.h"
20 #include "CiteEnginesList.h"
22 #include "DispatchResult.h"
26 #include "FuncRequest.h"
27 #include "FuncStatus.h"
28 #include "LaTeXFeatures.h"
29 #include "output_latex.h"
30 #include "output_xhtml.h"
31 #include "OutputParams.h"
32 #include "PDFOptions.h"
33 #include "texstream.h"
34 #include "TextClass.h"
36 #include "frontends/alert.h"
38 #include "support/convert.h"
39 #include "support/debug.h"
40 #include "support/docstream.h"
41 #include "support/ExceptionMessage.h"
42 #include "support/FileNameList.h"
43 #include "support/filetools.h"
44 #include "support/gettext.h"
45 #include "support/lstrings.h"
46 #include "support/os.h"
47 #include "support/PathChanger.h"
48 #include "support/textutils.h"
53 using namespace lyx::support;
57 namespace Alert = frontend::Alert;
58 namespace os = support::os;
61 InsetBibtex::InsetBibtex(Buffer * buf, InsetCommandParams const & p)
62 : InsetCommand(buf, p)
66 ParamInfo const & InsetBibtex::findInfo(string const & /* cmdName */)
68 static ParamInfo param_info_;
69 if (param_info_.empty()) {
70 param_info_.add("btprint", ParamInfo::LATEX_OPTIONAL);
71 param_info_.add("bibfiles", ParamInfo::LATEX_REQUIRED);
72 param_info_.add("options", ParamInfo::LYX_INTERNAL);
73 param_info_.add("encoding", ParamInfo::LYX_INTERNAL);
74 param_info_.add("biblatexopts", ParamInfo::LATEX_OPTIONAL);
80 void InsetBibtex::doDispatch(Cursor & cur, FuncRequest & cmd)
82 switch (cmd.action()) {
88 case LFUN_INSET_MODIFY: {
89 InsetCommandParams p(BIBTEX_CODE);
91 if (!InsetCommand::string2params(to_utf8(cmd.argument()), p)) {
95 } catch (ExceptionMessage const & message) {
96 if (message.type_ == WarningException) {
97 Alert::warning(message.title_, message.details_);
106 cur.forceBufferUpdate();
111 InsetCommand::doDispatch(cur, cmd);
117 bool InsetBibtex::getStatus(Cursor & cur, FuncRequest const & cmd,
118 FuncStatus & flag) const
120 switch (cmd.action()) {
121 case LFUN_INSET_EDIT:
122 flag.setEnabled(true);
126 return InsetCommand::getStatus(cur, cmd, flag);
131 void InsetBibtex::editDatabases() const
133 vector<docstring> bibfilelist = getVectorFromString(getParam("bibfiles"));
135 if (bibfilelist.empty())
138 int nr_databases = bibfilelist.size();
139 if (nr_databases > 1) {
140 docstring const engine = usingBiblatex() ? _("Biblatex") : _("BibTeX");
141 docstring message = bformat(_("The %1$s[[BibTeX/Biblatex]] inset includes %2$s databases.\n"
142 "If you proceed, all of them will be opened."),
143 engine, convert<docstring>(nr_databases));
144 int const ret = Alert::prompt(_("Open Databases?"),
145 message, 0, 1, _("&Cancel"), _("&Proceed"));
151 vector<docstring>::const_iterator it = bibfilelist.begin();
152 vector<docstring>::const_iterator en = bibfilelist.end();
153 for (; it != en; ++it) {
154 FileName const bibfile = getBibTeXPath(*it, buffer());
155 theFormats().edit(buffer(), bibfile,
156 theFormats().getFormatFromFile(bibfile));
161 bool InsetBibtex::usingBiblatex() const
163 return buffer().masterParams().useBiblatex();
167 docstring InsetBibtex::screenLabel() const
169 return usingBiblatex() ? _("Biblatex Generated Bibliography")
170 : _("BibTeX Generated Bibliography");
174 docstring InsetBibtex::toolTip(BufferView const & /*bv*/, int /*x*/, int /*y*/) const
176 docstring tip = _("Databases:");
177 vector<docstring> bibfilelist = getVectorFromString(getParam("bibfiles"));
180 if (bibfilelist.empty())
181 tip += "<li>" + _("none") + "</li>";
183 for (docstring const & bibfile : bibfilelist)
184 tip += "<li>" + bibfile + "</li>";
189 docstring style = getParam("options"); // maybe empty! and with bibtotoc
190 docstring bibtotoc = from_ascii("bibtotoc");
191 if (prefixIs(style, bibtotoc)) {
193 if (contains(style, char_type(',')))
194 style = split(style, bibtotoc, char_type(','));
197 docstring const btprint = getParam("btprint");
198 if (!usingBiblatex()) {
199 tip += _("Style File:");
200 tip += "<ul><li>" + (style.empty() ? _("none") : style) + "</li></ul>";
202 tip += _("Lists:") + " ";
203 if (btprint == "btPrintAll")
204 tip += _("all references");
205 else if (btprint == "btPrintNotCited")
206 tip += _("all uncited references");
208 tip += _("all cited references");
211 tip += _("included in TOC");
213 if (!buffer().parent()
214 && buffer().params().multibib == "child") {
216 tip += _("Note: This bibliography is not output, since bibliographies in the master file "
217 "are not allowed with the setting 'Multiple bibliographies per child document'");
220 tip += _("Lists:") + " ";
221 if (btprint == "bibbysection")
222 tip += _("all reference units");
223 else if (btprint == "btPrintAll")
224 tip += _("all references");
226 tip += _("all cited references");
229 tip += _("included in TOC");
231 if (!getParam("biblatexopts").empty()) {
234 tip += _("Options: ") + getParam("biblatexopts");
242 void InsetBibtex::latex(otexstream & os, OutputParams const & runparams) const
244 // The sequence of the commands:
245 // With normal BibTeX:
246 // 1. \bibliographystyle{style}
247 // 2. \addcontentsline{...} - if option bibtotoc set
248 // 3. \bibliography{database}
250 // 1. \bibliographystyle{style}
251 // 2. \begin{btSect}{database}
252 // 3. \btPrint{Cited|NotCited|All}
255 // \printbibliography[biblatexopts]
257 // \bibbysection[biblatexopts] - if btprint is "bibbysection"
259 // chapterbib does not allow bibliographies in the master
260 if (!usingBiblatex() && !runparams.is_child
261 && buffer().params().multibib == "child")
264 string style = to_utf8(getParam("options")); // maybe empty! and with bibtotoc
266 if (prefixIs(style, "bibtotoc")) {
267 bibtotoc = "bibtotoc";
268 if (contains(style, ','))
269 style = split(style, bibtotoc, ',');
272 if (usingBiblatex()) {
274 string opts = to_utf8(getParam("biblatexopts"));
276 if (!bibtotoc.empty())
277 opts = opts.empty() ? "heading=bibintoc" : "heading=bibintoc," + opts;
278 // The bibliography command
279 docstring btprint = getParam("btprint");
280 if (btprint == "btPrintAll")
281 os << "\\nocite{*}\n";
282 if (btprint == "bibbysection" && !buffer().masterParams().multibib.empty())
283 os << "\\bibbysection";
285 os << "\\printbibliography";
287 os << "[" << opts << "]";
289 } else {// using BibTeX
291 vector<docstring> const db_out =
292 buffer().prepareBibFilePaths(runparams, getBibFiles(), false);
294 if (style == "default")
295 style = buffer().masterParams().defaultBiblioStyle();
296 if (!style.empty() && !buffer().masterParams().useBibtopic()) {
297 string base = buffer().masterBuffer()->prepareFileNameForLaTeX(style, ".bst", runparams.nice);
298 FileName const try_in_file =
299 makeAbsPath(base + ".bst", buffer().filePath());
300 bool const not_from_texmf = try_in_file.isReadableFile();
301 // If this style does not come from texmf and we are not
302 // exporting to .tex copy it to the tmp directory.
303 // This prevents problems with spaces and 8bit characters
305 if (!runparams.inComment && !runparams.dryrun && !runparams.nice &&
307 // use new style name
308 DocFileName const in_file = DocFileName(try_in_file);
309 base = removeExtension(in_file.mangledFileName());
310 FileName const out_file = makeAbsPath(base + ".bst",
311 buffer().masterBuffer()->temppath());
312 bool const success = in_file.copyTo(out_file);
314 LYXERR0("Failed to copy '" << in_file
315 << "' to '" << out_file << "'");
319 os << "\\bibliographystyle{"
320 << from_utf8(latex_path(buffer().prepareFileNameForLaTeX(base, ".bst", runparams.nice)))
323 // Warn about spaces in bst path. Warn only once.
324 static bool warned_about_bst_spaces = false;
325 if (!warned_about_bst_spaces && runparams.nice && contains(style, ' ')) {
326 warned_about_bst_spaces = true;
327 Alert::warning(_("Export Warning!"),
328 _("There are spaces in the path to your BibTeX style file.\n"
329 "BibTeX will be unable to find it."));
332 bool encoding_switched = false;
333 Encoding const * const save_enc = runparams.encoding;
334 docstring const encoding = getParam("encoding");
335 if (!encoding.empty() && encoding != from_ascii("default")) {
336 Encoding const * const enc = encodings.fromLyXName(to_ascii(encoding));
337 if (enc != runparams.encoding) {
339 switchEncoding(os.os(), buffer().params(), runparams, *enc, true);
340 runparams.encoding = enc;
341 encoding_switched = true;
344 // Handle the bibtopic case
345 if (!db_out.empty() && buffer().masterParams().useBibtopic()) {
346 os << "\\begin{btSect}";
348 os << "[" << style << "]";
349 os << "{" << getStringFromVector(db_out) << "}\n";
350 docstring btprint = getParam("btprint");
353 btprint = from_ascii("btPrintCited");
354 os << "\\" << btprint << "\n"
355 << "\\end{btSect}\n";
358 if (!bibtotoc.empty() && !buffer().masterParams().useBibtopic()) {
359 // set label for hyperref, see http://www.lyx.org/trac/ticket/6470
360 if (buffer().masterParams().pdfoptions().use_hyperref)
361 os << "\\phantomsection";
362 if (buffer().masterParams().documentClass().hasLaTeXLayout("chapter"))
363 os << "\\addcontentsline{toc}{chapter}{\\bibname}";
364 else if (buffer().masterParams().documentClass().hasLaTeXLayout("section"))
365 os << "\\addcontentsline{toc}{section}{\\refname}";
367 // The bibliography command
368 if (!db_out.empty() && !buffer().masterParams().useBibtopic()) {
369 docstring btprint = getParam("btprint");
370 if (btprint == "btPrintAll") {
371 os << "\\nocite{*}\n";
373 os << "\\bibliography{" << getStringFromVector(db_out) << "}\n";
375 if (encoding_switched){
377 switchEncoding(os.os(), buffer().params(),
378 runparams, *save_enc, true, true);
379 os << "\\egroup" << breakln;
380 runparams.encoding = save_enc;
386 FileNamePairList InsetBibtex::getBibFiles() const
388 FileName path(buffer().filePath());
391 // We need to store both the real FileName and the way it is entered
392 // (with full path, rel path or as a single file name).
393 // The latter is needed for biblatex's central bibfile macro.
394 FileNamePairList vec;
396 vector<docstring> bibfilelist = getVectorFromString(getParam("bibfiles"));
397 vector<docstring>::const_iterator it = bibfilelist.begin();
398 vector<docstring>::const_iterator en = bibfilelist.end();
399 for (; it != en; ++it) {
400 FileName const file = getBibTeXPath(*it, buffer());
403 vec.push_back(make_pair(*it, file));
405 LYXERR0("Couldn't find " + to_utf8(*it) + " in InsetBibtex::getBibFiles()!");
413 // methods for parsing bibtex files
415 typedef map<docstring, docstring> VarMap;
417 /// remove whitespace characters, optionally a single comma,
418 /// and further whitespace characters from the stream.
419 /// @return true if a comma was found, false otherwise
421 bool removeWSAndComma(ifdocstream & ifs) {
430 } while (ifs && isSpace(ch));
443 } while (ifs && isSpace(ch));
458 /// remove whitespace characters, read characer sequence
459 /// not containing whitespace characters or characters in
460 /// delimChars, and remove further whitespace characters.
462 /// @return true if a string of length > 0 could be read.
464 bool readTypeOrKey(docstring & val, ifdocstream & ifs,
465 docstring const & delimChars, docstring const & illegalChars,
478 } while (ifs && isSpace(ch));
484 while (ifs && !isSpace(ch) &&
485 delimChars.find(ch) == docstring::npos &&
486 illegalChars.find(ch) == docstring::npos)
488 if (chCase == makeLowerCase)
489 val += lowercase(ch);
495 if (illegalChars.find(ch) != docstring::npos) {
501 while (ifs && isSpace(ch)) {
509 return val.length() > 0;
512 /// read subsequent bibtex values that are delimited with a #-character.
513 /// Concatenate all parts and replace names with the associated string in
514 /// the variable strings.
515 /// @return true if reading was successfull (all single parts were delimited
517 bool readValue(docstring & val, ifdocstream & ifs, const VarMap & strings) {
530 } while (ifs && isSpace(ch));
535 // check for field type
536 if (isDigitASCII(ch)) {
538 // read integer value
542 } while (ifs && isDigitASCII(ch));
547 } else if (ch == '"' || ch == '{') {
549 char_type delim = ch == '"' ? '"': '}';
554 } while (ifs && isSpace(ch));
559 // We now have the first non-whitespace character
560 // We'll collapse adjacent whitespace.
561 bool lastWasWhiteSpace = false;
563 // inside this delimited text braces must match.
564 // Thus we can have a closing delimiter only
565 // when nestLevel == 0
568 while (ifs && (nestLevel > 0 || ch != delim)) {
570 lastWasWhiteSpace = true;
574 // We output the space only after we stop getting
575 // whitespace so as not to output any whitespace
576 // at the end of the value.
577 if (lastWasWhiteSpace) {
578 lastWasWhiteSpace = false;
584 // update nesting level
603 // FIXME Why is this here?
611 // reading a string name
614 while (ifs && !isSpace(ch) && ch != '#' && ch != ',' && ch != '}' && ch != ')') {
615 strName += lowercase(ch);
622 // replace the string with its assigned value or
623 // discard it if it's not assigned
624 if (strName.length()) {
625 VarMap::const_iterator pos = strings.find(strName);
626 if (pos != strings.end()) {
633 while (ifs && isSpace(ch)) {
640 // continue reading next value on concatenate with '#'
650 void InsetBibtex::collectBibKeys(InsetIterator const & /*di*/, FileNameList & checkedFiles) const
652 parseBibTeXFiles(checkedFiles);
656 void InsetBibtex::parseBibTeXFiles(FileNameList & checkedFiles) const
658 // This bibtex parser is a first step to parse bibtex files
661 // - it reads the whole bibtex entry and does a syntax check
662 // (matching delimiters, missing commas,...
663 // - it recovers from errors starting with the next @-character
664 // - it reads @string definitions and replaces them in the
666 // - it accepts more characters in keys or value names than
669 // Officially bibtex does only support ASCII, but in practice
670 // you can use any encoding as long as some elements like keys
671 // and names are pure ASCII. We support specifying an encoding,
672 // and we convert the file from that (default is buffer encoding).
673 // We don't restrict keys to ASCII in LyX, since our own
674 // InsetBibitem can generate non-ASCII keys, and nonstandard
675 // 8bit clean bibtex forks exist.
679 FileNamePairList const files = getBibFiles();
680 FileNamePairList::const_iterator it = files.begin();
681 FileNamePairList::const_iterator en = files.end();
682 for (; it != en; ++ it) {
683 FileName const bibfile = it->second;
684 if (find(checkedFiles.begin(), checkedFiles.end(), bibfile) != checkedFiles.end())
685 // already checked this one. Skip.
688 // record that we check this.
689 checkedFiles.push_back(bibfile);
690 string encoding = buffer().masterParams().encoding().iconvName();
691 string const ienc = to_ascii(params()["encoding"]);
692 if (!ienc.empty() && ienc != "default" && encodings.fromLyXName(ienc))
693 encoding = encodings.fromLyXName(ienc)->iconvName();
694 ifdocstream ifs(bibfile.toFilesystemEncoding().c_str(),
695 ios_base::in, encoding);
711 if (!readTypeOrKey(entryType, ifs, from_ascii("{("), docstring(), makeLowerCase)) {
712 lyxerr << "BibTeX Parser: Error reading entry type." << std::endl;
717 lyxerr << "BibTeX Parser: Unexpected end of file." << std::endl;
721 if (entryType == from_ascii("comment")) {
722 ifs.ignore(numeric_limits<int>::max(), '\n');
728 lyxerr << "BibTeX Parser: Unexpected end of file." << std::endl;
732 if ((ch != '(') && (ch != '{')) {
733 lyxerr << "BibTeX Parser: Invalid entry delimiter." << std::endl;
739 if (entryType == from_ascii("string")) {
741 // read string and add it to the strings map
742 // (or replace it's old value)
746 if (!readTypeOrKey(name, ifs, from_ascii("="), from_ascii("#{}(),"), makeLowerCase)) {
747 lyxerr << "BibTeX Parser: Error reading string name." << std::endl;
752 lyxerr << "BibTeX Parser: Unexpected end of file." << std::endl;
756 // next char must be an equal sign
758 if (!ifs || ch != '=') {
759 lyxerr << "BibTeX Parser: No `=' after string name: " <<
760 name << "." << std::endl;
764 if (!readValue(value, ifs, strings)) {
765 lyxerr << "BibTeX Parser: Unable to read value for string: " <<
766 name << "." << std::endl;
770 strings[name] = value;
772 } else if (entryType == from_ascii("preamble")) {
774 // preamble definitions are discarded.
775 // can they be of any use in lyx?
778 if (!readValue(value, ifs, strings)) {
779 lyxerr << "BibTeX Parser: Unable to read preamble value." << std::endl;
785 // Citation entry. Try to read the key.
788 if (!readTypeOrKey(key, ifs, from_ascii(","), from_ascii("}"), keepCase)) {
789 lyxerr << "BibTeX Parser: Unable to read key for entry type:" <<
790 entryType << "." << std::endl;
795 lyxerr << "BibTeX Parser: Unexpected end of file." << std::endl;
799 /////////////////////////////////////////////
800 // now we have a key, so we will add an entry
801 // (even if it's empty, as bibtex does)
803 // we now read the field = value pairs.
804 // all items must be separated by a comma. If
805 // it is missing the scanning of this entry is
806 // stopped and the next is searched.
810 BibTeXInfo keyvalmap(key, entryType);
812 bool readNext = removeWSAndComma(ifs);
814 while (ifs && readNext) {
817 if (!readTypeOrKey(name, ifs, from_ascii("="),
818 from_ascii("{}(),"), makeLowerCase) || !ifs)
821 // next char must be an equal sign
822 // FIXME Whitespace??
825 lyxerr << "BibTeX Parser: Unexpected end of file." << std::endl;
829 lyxerr << "BibTeX Parser: Missing `=' after field name: " <<
830 name << ", for key: " << key << "." << std::endl;
836 if (!readValue(value, ifs, strings)) {
837 lyxerr << "BibTeX Parser: Unable to read value for field: " <<
838 name << ", for key: " << key << "." << std::endl;
842 keyvalmap[name] = value;
843 data += "\n\n" + value;
844 keylist.addFieldName(name);
845 readNext = removeWSAndComma(ifs);
849 keylist.addEntryType(entryType);
850 keyvalmap.setAllData(data);
851 keylist[key] = keyvalmap;
852 } //< else (citation entry)
854 } //< for loop over files
856 buffer().addBiblioInfo(keylist);
860 FileName InsetBibtex::getBibTeXPath(docstring const & filename, Buffer const & buf)
862 string texfile = changeExtension(to_utf8(filename), "bib");
863 // note that, if the filename can be found directly from the path,
864 // findtexfile will just return a FileName object for that path.
865 FileName file(findtexfile(texfile, "bib"));
867 file = FileName(makeAbsPath(texfile, buf.filePath()));
872 bool InsetBibtex::addDatabase(docstring const & db)
874 docstring bibfiles = getParam("bibfiles");
875 if (tokenPos(bibfiles, ',', db) != -1)
877 if (!bibfiles.empty())
879 setParam("bibfiles", bibfiles + db);
884 bool InsetBibtex::delDatabase(docstring const & db)
886 docstring bibfiles = getParam("bibfiles");
887 if (contains(bibfiles, db)) {
888 int const n = tokenPos(bibfiles, ',', db);
891 // this is not the first database
892 docstring tmp = ',' + bd;
893 setParam("bibfiles", subst(bibfiles, tmp, docstring()));
895 // this is the first (or only) database
896 setParam("bibfiles", split(bibfiles, bd, ','));
904 void InsetBibtex::validate(LaTeXFeatures & features) const
906 BufferParams const & mparams = features.buffer().masterParams();
907 if (mparams.useBibtopic())
908 features.require("bibtopic");
909 else if (!mparams.useBiblatex() && mparams.multibib == "child")
910 features.require("chapterbib");
912 // It'd be better to be able to get this from an InsetLayout, but at present
913 // InsetLayouts do not seem really to work for things that aren't InsetTexts.
914 if (features.runparams().flavor == OutputParams::HTML)
915 features.addCSSSnippet("div.bibtexentry { margin-left: 2em; text-indent: -2em; }\n"
916 "span.bibtexlabel:before{ content: \"[\"; }\n"
917 "span.bibtexlabel:after{ content: \"] \"; }");
921 void InsetBibtex::updateBuffer(ParIterator const &, UpdateType)
923 buffer().registerBibfiles(getBibFiles());
924 // record encoding of bib files for biblatex
925 string const enc = (params()["encoding"] == from_ascii("default")) ?
926 string() : to_ascii(params()["encoding"]);
927 if (buffer().params().bibEncoding() != enc) {
928 buffer().params().setBibEncoding(enc);
929 buffer().reloadBibInfoCache(true);
934 int InsetBibtex::plaintext(odocstringstream & os,
935 OutputParams const & op, size_t max_length) const
937 docstring const reflabel = buffer().B_("References");
939 // We could output more information here, e.g., what databases are included
940 // and information about options. But I don't necessarily see any reason to
941 // do this right now.
942 if (op.for_tooltip || op.for_toc || op.for_search) {
943 os << '[' << reflabel << ']' << '\n';
944 return PLAINTEXT_NEWLINE;
947 BiblioInfo bibinfo = buffer().masterBibInfo();
948 bibinfo.makeCitationLabels(buffer());
949 vector<docstring> const & cites = bibinfo.citedEntries();
951 size_t start_size = os.str().size();
953 refoutput += reflabel + "\n\n";
955 // Tell BiblioInfo our purpose
957 ci.context = CiteItem::Export;
959 // Now we loop over the entries
960 vector<docstring>::const_iterator vit = cites.begin();
961 vector<docstring>::const_iterator const ven = cites.end();
962 for (; vit != ven; ++vit) {
963 if (start_size + refoutput.size() >= max_length)
965 BiblioInfo::const_iterator const biit = bibinfo.find(*vit);
966 if (biit == bibinfo.end())
968 BibTeXInfo const & entry = biit->second;
969 refoutput += "[" + entry.label() + "] ";
970 // FIXME Right now, we are calling BibInfo::getInfo on the key,
971 // which will give us all the cross-referenced info. But for every
972 // entry, so there's a lot of repitition. This should be fixed.
973 refoutput += bibinfo.getInfo(entry.key(), buffer(), ci) + "\n\n";
976 return refoutput.size();
981 // docstring InsetBibtex::entriesAsXHTML(vector<docstring> const & entries)
982 // And then here just: entriesAsXHTML(buffer().masterBibInfo().citedEntries())
983 docstring InsetBibtex::xhtml(XHTMLStream & xs, OutputParams const &) const
985 BiblioInfo const & bibinfo = buffer().masterBibInfo();
986 bool const all_entries = getParam("btprint") == "btPrintAll";
987 vector<docstring> const & cites =
988 all_entries ? bibinfo.getKeys() : bibinfo.citedEntries();
990 docstring const reflabel = buffer().B_("References");
992 // tell BiblioInfo our purpose
994 ci.context = CiteItem::Export;
996 ci.max_key_size = UINT_MAX;
998 xs << html::StartTag("h2", "class='bibtex'")
1000 << html::EndTag("h2")
1001 << html::StartTag("div", "class='bibtex'");
1003 // Now we loop over the entries
1004 vector<docstring>::const_iterator vit = cites.begin();
1005 vector<docstring>::const_iterator const ven = cites.end();
1006 for (; vit != ven; ++vit) {
1007 BiblioInfo::const_iterator const biit = bibinfo.find(*vit);
1008 if (biit == bibinfo.end())
1011 BibTeXInfo const & entry = biit->second;
1012 string const attr = "class='bibtexentry' id='LyXCite-"
1013 + to_utf8(html::cleanAttr(entry.key())) + "'";
1014 xs << html::StartTag("div", attr);
1016 // don't print labels if we're outputting all entries
1018 xs << html::StartTag("span", "class='bibtexlabel'")
1020 << html::EndTag("span");
1023 // FIXME Right now, we are calling BibInfo::getInfo on the key,
1024 // which will give us all the cross-referenced info. But for every
1025 // entry, so there's a lot of repitition. This should be fixed.
1026 xs << html::StartTag("span", "class='bibtexinfo'")
1027 << XHTMLStream::ESCAPE_AND
1028 << bibinfo.getInfo(entry.key(), buffer(), ci)
1029 << html::EndTag("span")
1030 << html::EndTag("div")
1033 xs << html::EndTag("div");
1038 void InsetBibtex::write(ostream & os) const
1040 params().Write(os, &buffer());
1044 string InsetBibtex::contextMenuName() const
1046 return "context-bibtex";