]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetBibtex.cpp
How about if we write a script to do some of this and stop doing it
[lyx.git] / src / insets / InsetBibtex.cpp
index f80afbb0f9f04276c92637fa50618a0a33097f45..a38f4a7bb4c6da5a465e2f977ff0e816522f1d90 100644 (file)
@@ -898,6 +898,15 @@ void InsetBibtex::validate(LaTeXFeatures & features) const
 {
        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>");
 }
 
 
@@ -927,7 +936,9 @@ docstring InsetBibtex::xhtml(XHTMLStream & xs, OutputParams const &) const
        if (citekeys.empty())
                return docstring();
        sort(citekeys.begin(), citekeys.end());
-       unique(citekeys.begin(), citekeys.end());
+       vector<docstring>::iterator uit = 
+               unique(citekeys.begin(), citekeys.end());
+       citekeys.erase(uit, citekeys.end());
        // We now have a sorted, unique list of the keys used in this document.
        // We will now convert it to a list of the BibTeXInfo objects used in 
        // this document...
@@ -937,24 +948,24 @@ docstring InsetBibtex::xhtml(XHTMLStream & xs, OutputParams const &) const
        BiblioInfo const & bi = buffer().masterBibInfo();
        for (; cit != cen; ++cit) {
                BiblioInfo::const_iterator const bt = bi.find(*cit);
-               if (bt == bi.end())
+               if (bt == bi.end() || !bt->second.isBibTeX())
                        continue;
                binfo.push_back(&(bt->second));
        }
        // ...and sort it.
        sort(binfo.begin(), binfo.end(), lSorter);
        // Finally, then, we are ready for output.
-       xs << StartTag("h2", "class='bibliography'");
-       xs << _("References");
-       xs << EndTag("h2");
-       xs << StartTag("div", "class='bibliography'");
+       xs << StartTag("h2", "class='bibtex'")
+               << _("References")
+               << EndTag("h2")
+               << StartTag("div", "class='bibtex'");
 
        // Now we loop over the entries
        vector<BibTeXInfo const *>::const_iterator vit = binfo.begin();
        vector<BibTeXInfo const *>::const_iterator const ven = binfo.end();
        for (; vit != ven; ++vit) {
                BibTeXInfo const * bip = *vit;
-               xs << StartTag("div", "class='bibentry'");
+               xs << StartTag("div", "class='bibtexentry'");
                // FIXME XHTML
                // The same name/id problem we have elsewhere.
                string const attr = "id='" + to_utf8(bip->key()) + "'";
@@ -962,16 +973,16 @@ docstring InsetBibtex::xhtml(XHTMLStream & xs, OutputParams const &) const
                docstring label = bip->label();
                if (label.empty())
                        label = bip->key();
-               xs << StartTag("span", "class='biblabel'");
-               xs << "[" << label << "] ";
-               xs << EndTag("span");
+               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='bibinfo'");
-               xs << bi.getInfo(bip->key());
-               xs << EndTag("span");
-               xs << EndTag("div");
+               xs << StartTag("span", "class='bibtexinfo'") 
+                       << bi.getInfo(bip->key())
+                       << EndTag("span")
+                       << EndTag("div");
        }
        xs << EndTag("div");
        return docstring();