mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-26 06:15:16 +00:00
OK, now here's a big one: XHTML output for InsetBibtex. It's not perfect---
see the notes---but it does work reasonably well. And it will work a lot better when an unrelated patch of mine goes in: one that generally improves the display of BibTeX-derived information. Note how we use the TOC here, which has already gathered the information we need. This can also be done for other things. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30056 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
0a06e2a131
commit
e28c88767b
@ -17,6 +17,14 @@ These insets do nothing for XHTML:
|
||||
ERT, OptArg, Phantom
|
||||
|
||||
These insets work but still need work:
|
||||
InsetBibtex: There are a few issues here. One is that the output is not very
|
||||
nice. This will be solved, though, by a patch of mine I seem to have forgotten
|
||||
to finish. To get output that accorded with the BibTeX style, of course, we'd
|
||||
have to parse the bbl file. I don't know if that's worth it.
|
||||
Another issue concerns cross-references. At the moment, we simply use the
|
||||
xref information for every entry, rather than listing the xref separately and
|
||||
then referencing it. That should not be terribly hard, but it would take a bit
|
||||
of work.
|
||||
InsetBox: We need a Length::asHTML() method and the like, but it basically works.
|
||||
though the CSS isn't there yet.
|
||||
InsetCitation: This has two limitations as of 11 VI 2009. The first is that we
|
||||
@ -37,10 +45,6 @@ May need to make use here of TocWidget::itemInset, which should then be moved
|
||||
to TocBackend.
|
||||
|
||||
These do not yet work and need some attention:
|
||||
InsetBibtex: We should be able to collect the keys of references in
|
||||
validate() and then use our parsed information to output some sort of
|
||||
bibliography. Formatting is another question, but here again we could
|
||||
try parsing the bbl file.
|
||||
InsetCommand: By default does nothing. That may be right?
|
||||
InsetExternal: I don't understand these so am not sure what to do.
|
||||
InsetFloat: This will need some work, again because I do not really understand
|
||||
|
@ -22,8 +22,10 @@
|
||||
#include "FuncStatus.h"
|
||||
#include "LaTeXFeatures.h"
|
||||
#include "MetricsInfo.h"
|
||||
#include "output_xhtml.h"
|
||||
#include "OutputParams.h"
|
||||
#include "TextClass.h"
|
||||
#include "TocBackend.h"
|
||||
|
||||
#include "frontends/alert.h"
|
||||
|
||||
@ -900,9 +902,78 @@ void InsetBibtex::validate(LaTeXFeatures & features) const
|
||||
}
|
||||
|
||||
|
||||
int InsetBibtex::xhtml(odocstream &, OutputParams const &) const
|
||||
namespace {
|
||||
// used in xhtml to sort a list of BibTeXInfo objects
|
||||
bool lSorter(BibTeXInfo const * lhs, BibTeXInfo const * rhs)
|
||||
{
|
||||
return lhs->getAbbreviatedAuthor() < rhs->getAbbreviatedAuthor();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int InsetBibtex::xhtml(odocstream & os, OutputParams const &) const
|
||||
{
|
||||
//Toc const & toc = buffer().tocBackend().toc("citation");
|
||||
// We are going to collect all the citation keys used in the document,
|
||||
// getting them from the TOC.
|
||||
Toc const & toc = buffer().tocBackend().toc("citation");
|
||||
Toc::const_iterator it = toc.begin();
|
||||
Toc::const_iterator en = toc.end();
|
||||
vector<docstring> citekeys;
|
||||
for (; it != en; ++it) {
|
||||
if (it->str().empty())
|
||||
continue;
|
||||
vector<docstring> keys = getVectorFromString(it->str());
|
||||
vector<docstring>::const_iterator dit = keys.begin();
|
||||
vector<docstring>::const_iterator den = keys.end();
|
||||
for (; dit != den; ++dit)
|
||||
citekeys.push_back(*dit);
|
||||
}
|
||||
if (citekeys.empty())
|
||||
return 0;
|
||||
sort(citekeys.begin(), citekeys.end());
|
||||
unique(citekeys.begin(), 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...
|
||||
// FIXME We need to do something here about cross-references, if we
|
||||
// want to be able to display them AS cross-references. Probably the
|
||||
// easiest thing to do is to loop over the list again and add whatever
|
||||
// cross-references we find, then sort and unique it, planning just to
|
||||
// add the cross-references to the bibliography.
|
||||
vector<BibTeXInfo const *> binfo;
|
||||
vector<docstring>::const_iterator cit = citekeys.begin();
|
||||
vector<docstring>::const_iterator cen = citekeys.end();
|
||||
BiblioInfo const & bi = buffer().masterBibInfo();
|
||||
for (; cit != cen; ++cit) {
|
||||
BiblioInfo::const_iterator bt = bi.find(*cit);
|
||||
if (bt == bi.end())
|
||||
continue;
|
||||
binfo.push_back(&(bt->second));
|
||||
}
|
||||
// ...and sort it.
|
||||
sort(binfo.begin(), binfo.end(), lSorter);
|
||||
// Finally, then, we are ready for output.
|
||||
os << "<h2 class='bibliography'>" << _("References") << "</h2>\n";
|
||||
os << "<div class='bibliography'>\n";
|
||||
vector<BibTeXInfo const *>::const_iterator vit = binfo.begin();
|
||||
vector<BibTeXInfo const *>::const_iterator ven = binfo.end();
|
||||
// Now we loop over the entries
|
||||
for (; vit != ven; ++vit) {
|
||||
BibTeXInfo const * bip = *vit;
|
||||
os << "<p class='bibliography'>";
|
||||
os << "<a name='" << html::htmlize(bip->key()) << "'></a>";
|
||||
docstring label = bip->label();
|
||||
if (label.empty())
|
||||
label = bip->key();
|
||||
os << "<span class='biblabel'>[" << label << "]</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.
|
||||
os << "<span class='bibinfo'>" << bi.getInfo(bip->key()) << "</span>";
|
||||
os << "</p>\n";
|
||||
}
|
||||
|
||||
os << "</div>\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user