]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetBibitem.cpp
Routines for calculating numerical labels for BibTeX citations.
[lyx.git] / src / insets / InsetBibitem.cpp
index d79cb9b663fcb580cfeec85edcbc667e157aaee5..5eb0d448b4f646ef93430fcf7a3dcbda698eb1f8 100644 (file)
@@ -49,9 +49,8 @@ docstring const key_prefix = from_ascii("key-");
 
 
 InsetBibitem::InsetBibitem(Buffer * buf, InsetCommandParams const & p)
-       : InsetCommand(p, "bibitem")
+       : InsetCommand(buf, p, "bibitem")
 {
-       Inset::setBuffer(*buf);
        buffer_->invalidateBibinfoCache();
        if (getParam("key").empty())
                setParam("key", key_prefix + convert<docstring>(++key_counter));
@@ -255,7 +254,7 @@ void InsetBibitem::fillWithBibKeys(BiblioInfo & keys, InsetIterator const & it)
 
 
 // Update the counters of this inset and of its contents
-void InsetBibitem::updateLabels(ParIterator const & it
+void InsetBibitem::updateLabels(ParIterator const & it, bool)
 {
        BufferParams const & bp = buffer().masterBuffer()->params();
        Counters & counters = bp.documentClass().counters();
@@ -270,10 +269,19 @@ void InsetBibitem::updateLabels(ParIterator const & it)
 }
 
 
-docstring InsetBibitem::xhtml(odocstream & os, OutputParams const &) const
+docstring InsetBibitem::xhtml(XHTMLStream & xs, OutputParams const &) const
 {
-       os << "<a name='" << html::htmlize(getParam("key")) << "'></a>";
-       os << "<span class='biblabel'>" << bibLabel() << "</span> "; 
+       // FIXME XHTML
+       // XHTML 1.1 doesn't have the "name" attribute for <a>, so we have to use
+       // the "id" atttribute to get the document to validate. Probably, we will
+       // need to use "name" anyway, eventually, because some browsers do not
+       // handle jumping to ids. If we don't do that, though, we can just put the
+       // id into the span tag.
+       string const attrs = "id='" + to_utf8(getParam("key")) + "'";
+       xs << CompTag("a", attrs);
+       xs << StartTag("span", "class='bibitemlabel'");
+       xs << bibLabel();
+       xs << EndTag("span");
        return docstring();
 }