+ // FIXME XHTML
+ // It'd be better to be able to get this from an InsetLayout, but at present
+ // InsetLayouts do not seem really to work for things that aren't InsetTexts.
+ if (features.runparams().flavor == OutputParams::HTML)
+ features.addCSSSnippet("div.bibtexentry { margin-left: 2em; text-indent: -2em; }\n"
+ "span.bibtexlabel:before{ content: \"[\"; }\n"
+ "span.bibtexlabel:after{ content: \"] \"; }");
+}
+
+
+int InsetBibtex::plaintext(odocstringstream & os,
+ OutputParams const & op, size_t max_length) const
+{
+ docstring const reflabel = buffer().B_("References");
+
+ // We could output more information here, e.g., what databases are included
+ // and information about options. But I don't necessarily see any reason to
+ // do this right now.
+ if (op.for_tooltip || op.for_toc || op.for_search) {
+ os << '[' << reflabel << ']' << '\n';
+ return PLAINTEXT_NEWLINE;
+ }
+
+ BiblioInfo bibinfo = buffer().masterBibInfo();
+ bibinfo.makeCitationLabels(buffer());
+ vector<docstring> const & cites = bibinfo.citedEntries();
+
+ size_t start_size = os.str().size();
+ docstring refoutput;
+ refoutput += reflabel + "\n\n";
+
+ // Now we loop over the entries
+ vector<docstring>::const_iterator vit = cites.begin();
+ vector<docstring>::const_iterator const ven = cites.end();
+ for (; vit != ven; ++vit) {
+ if (start_size + refoutput.size() >= max_length)
+ break;
+ BiblioInfo::const_iterator const biit = bibinfo.find(*vit);
+ if (biit == bibinfo.end())
+ continue;
+ BibTeXInfo const & entry = biit->second;
+ refoutput += "[" + entry.label() + "] ";
+ // FIXME Right now, we are calling BibInfo::getInfo on the key,
+ // which will give us all the cross-referenced info. But for every
+ // entry, so there's a lot of repitition. This should be fixed.
+ refoutput += bibinfo.getInfo(entry.key(), buffer(), false) + "\n\n";
+ }
+ os << refoutput;
+ return refoutput.size();
+}
+
+
+// FIXME
+// docstring InsetBibtex::entriesAsXHTML(vector<docstring> const & entries)
+// And then here just: entriesAsXHTML(buffer().masterBibInfo().citedEntries())
+docstring InsetBibtex::xhtml(XHTMLStream & xs, OutputParams const &) const
+{
+ BiblioInfo const & bibinfo = buffer().masterBibInfo();
+ bool const all_entries = getParam("btprint") == "btPrintAll";
+ vector<docstring> const & cites =
+ all_entries ? bibinfo.getKeys() : bibinfo.citedEntries();
+
+ docstring const reflabel = buffer().B_("References");
+
+ xs << html::StartTag("h2", "class='bibtex'")
+ << reflabel
+ << html::EndTag("h2")
+ << html::StartTag("div", "class='bibtex'");
+
+ // Now we loop over the entries
+ vector<docstring>::const_iterator vit = cites.begin();
+ vector<docstring>::const_iterator const ven = cites.end();
+ for (; vit != ven; ++vit) {
+ BiblioInfo::const_iterator const biit = bibinfo.find(*vit);
+ if (biit == bibinfo.end())
+ continue;
+
+ BibTeXInfo const & entry = biit->second;
+ string const attr = "class='bibtexentry' id='LyXCite-"
+ + to_utf8(html::cleanAttr(entry.key())) + "'";
+ xs << html::StartTag("div", attr);
+
+ // don't print labels if we're outputting all entries
+ if (!all_entries) {
+ xs << html::StartTag("span", "class='bibtexlabel'")
+ << entry.label()
+ << html::EndTag("span");
+ }
+
+ // FIXME Right now, we are calling BibInfo::getInfo on the key,
+ // which will give us all the cross-referenced info. But for every
+ // entry, so there's a lot of repitition. This should be fixed.
+ xs << html::StartTag("span", "class='bibtexinfo'")
+ << XHTMLStream::ESCAPE_AND
+ << bibinfo.getInfo(entry.key(), buffer(), true)
+ << html::EndTag("span")
+ << html::EndTag("div")
+ << html::CR();
+ }
+ xs << html::EndTag("div");
+ return docstring();
+}
+
+
+void InsetBibtex::write(ostream & os) const
+{
+ params().Write(os, &buffer());