#include "FuncStatus.h"
#include "LaTeXFeatures.h"
#include "MetricsInfo.h"
+#include "output_xhtml.h"
#include "OutputParams.h"
#include "TextClass.h"
namespace os = support::os;
-InsetBibtex::InsetBibtex(Buffer const & buf, InsetCommandParams const & p)
- : InsetCommand(p, "bibtex")
+InsetBibtex::InsetBibtex(Buffer * buf, InsetCommandParams const & p)
+ : InsetCommand(buf, p, "bibtex")
{
- Inset::setBuffer(const_cast<Buffer &>(buf));
buffer_->invalidateBibinfoCache();
}
{
if (features.bufferParams().use_bibtopic)
features.require("bibtopic");
+ // 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.addPreambleSnippet("<style type=\"text/css\">\n"
+ "div.bibtexentry { margin-left: 2em; text-indent: -2em; }\n"
+ "span.bibtexlabel:before{ content: \"[\"; }\n"
+ "span.bibtexlabel:after{ content: \"] \"; }\n"
+ "</style>");
}
-int InsetBibtex::xhtml(odocstream &, OutputParams const &) const
+docstring InsetBibtex::xhtml(XHTMLStream & xs, OutputParams const &) const
{
- //Toc const & toc = buffer().tocBackend().toc("citation");
- return 0;
+ BiblioInfo const & bibinfo = buffer().masterBibInfo();
+ vector<docstring> const & cites = bibinfo.citedEntries();
+ xs << StartTag("h2", "class='bibtex'")
+ << _("References")
+ << EndTag("h2")
+ << 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;
+ xs << StartTag("div", "class='bibtexentry'");
+ // FIXME XHTML
+ // The same name/id problem we have elsewhere.
+ string const attr = "id='" + to_utf8(entry.key()) + "'";
+ xs << CompTag("a", attr);
+ docstring label = entry.label();
+ if (label.empty())
+ label = entry.key();
+ xs << StartTag("span", "class='bibtexlabel'")
+ << label
+ << 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 << StartTag("span", "class='bibtexinfo'")
+ << bibinfo.getInfo(entry.key())
+ << EndTag("span")
+ << EndTag("div");
+ }
+ xs << EndTag("div");
+ return docstring();
}