The branch, master, has been updated. - Log -----------------------------------------------------------------
commit 3408ca42044616bd169540ec901ce248e8290a61 Author: Julien Rioux <[email protected]> Date: Fri Jan 25 23:42:15 2013 +0100 Support for \fullcite in LyXHTML and text export (fixes #8491). diff --git a/lib/layouts/jurabib.module b/lib/layouts/jurabib.module index 63e016e..75b7d93 100644 --- a/lib/layouts/jurabib.module +++ b/lib/layouts/jurabib.module @@ -70,6 +70,7 @@ CiteFormat authoryear !citeauthor %!textbefore%%!startlink%%!shortauthor%%!endlink%%!textafter%%!nextauthor% !citeyear %!textbefore%%!startlink%%!year%%!endlink%%!textafter%%!nextyear% !citeyearpar %!textbefore%%!open%%!startlink%%!year%%!endlink%%!close%%!textafter%%!nextyearpar% + !fullcite {%textbefore%[[%textbefore% in: ]]}%bibentry%{%textafter%[[ %textafter%]]}%!nextfullcite% !nextcite {%next%[[%!sep% %!startlink%%!shortauthor%%!endlink%%!textafter2%%!nextcite%]]} !nextcitetitle {%next%[[%!sep% %!startlink%%!shortauthor%%!endlink%%!shorttitle%%!textafter2%%!nextcitetitle%]]} @@ -79,6 +80,7 @@ CiteFormat authoryear !nextauthor {%next%[[%!sep% %!citeauthor%]]} !nextyear {%next%[[%!sep% %!citeyear%]]} !nextyearpar {%next%[[%!sep% %!citeyearpar%]]} + !nextfullcite {%next%[[%!sep% %bibentry%{%textafter%[[ %textafter%]]}%!nextfullcite%]]} !nextkey {%next%[[%!sep% %key%%!nextkey%]]} !shortauthor {%shortauthor%[[%shortauthor%]][[??]]} @@ -99,6 +101,6 @@ CiteFormat authoryear citeauthor %!citeauthor% citeyear %!citeyear% citeyearpar %!citeyearpar% - fullcite {%dialog%[[%_bibentry%]][[%key%%!nextkey% (%_fullcite%)]]} + fullcite {%dialog%[[%_bibentry%]][[{%label%[[%!fullcite%]][[%key%%!nextkey% (%_fullcite%)]]}]]} nocite {%dialog%[[%_addtobib%]][[%key%%!nextkey% (%_notcited%)]]} End diff --git a/src/BiblioInfo.cpp b/src/BiblioInfo.cpp index 38883e8..84ea4f0 100644 --- a/src/BiblioInfo.cpp +++ b/src/BiblioInfo.cpp @@ -689,6 +689,14 @@ docstring BibTeXInfo::getValueForKey(string const & key, Buffer const & buf, + " [" + operator[]("year") + "]"; else return operator[]("title"); + } else if (key == "bibentry") { + // Special key to provide the full bibliography entry: see getInfo() + CiteEngineType const engine_type = buf.params().citeEngineType(); + DocumentClass const & dc = buf.params().documentClass(); + string const & format = dc.getCiteFormat(engine_type, to_utf8(entry_type_)); + int counter = 0; + return expandFormat(format, xref, counter, buf, + docstring(), docstring(), docstring(), false); } else if (key == "textbefore") return before; else if (key == "textafter") commit cc1ce047984292b0509043f82165c506d15eb020 Author: Julien Rioux <[email protected]> Date: Sat Feb 2 19:23:21 2013 +0100 Generate the citation labels before exporting to plain text. diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 05d6be2..530200c 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -2121,6 +2121,13 @@ void Buffer::addBibTeXInfo(docstring const & key, BibTeXInfo const & bi) const } +void Buffer::makeCitationLabels() const +{ + Buffer const * const master = masterBuffer(); + return d->bibinfo_.makeCitationLabels(*master); +} + + bool Buffer::citeLabelsValid() const { return masterBuffer()->d->cite_labels_valid_; diff --git a/src/Buffer.h b/src/Buffer.h index 3ed3a95..cd0540c 100644 --- a/src/Buffer.h +++ b/src/Buffer.h @@ -486,6 +486,8 @@ public: /// add a single piece of bibliography info to our cache void addBibTeXInfo(docstring const & key, BibTeXInfo const & bi) const; /// + void makeCitationLabels() const; + /// bool citeLabelsValid() const; /// void getLabelList(std::vector<docstring> &) const; diff --git a/src/insets/InsetCitation.cpp b/src/insets/InsetCitation.cpp index b1e48a6..60e3bbe 100644 --- a/src/insets/InsetCitation.cpp +++ b/src/insets/InsetCitation.cpp @@ -344,8 +344,13 @@ void InsetCitation::addToToc(DocIterator const & cpit) const int InsetCitation::plaintext(odocstream & os, OutputParams const &) const { - os << cache.generated_label; - return cache.generated_label.size(); + string const & cmd = getCmdName(); + if (cmd == "nocite") + return 0; + + docstring const label = generateLabel(false); + os << label; + return label.size(); } diff --git a/src/output_plaintext.cpp b/src/output_plaintext.cpp index f0a383d..476e62d 100644 --- a/src/output_plaintext.cpp +++ b/src/output_plaintext.cpp @@ -41,6 +41,7 @@ void writePlaintextFile(Buffer const & buf, FileName const & fname, // make sure we are ready to export buf.updateBuffer(); buf.updateMacroInstances(OutputUpdate); + buf.makeCitationLabels(); writePlaintextFile(buf, ofs, runparams); } commit 6456c2262e348f6bc81c4e59c68e35c045dfa2cb Author: Julien Rioux <[email protected]> Date: Fri Feb 1 16:18:37 2013 +0100 Move label generation from InsetBibtex to BiblioInfo. This only move the code, but does not change the displayed labels. Thus for numerical citation, the label is set to the cite number; for author-year citation, the abbreviated list of authors is used i.e. "Smith et al. 2001". Eventually, we might want to make the label customizable, or get it from BibTeX. diff --git a/src/BiblioInfo.cpp b/src/BiblioInfo.cpp index bf718c7..38883e8 100644 --- a/src/BiblioInfo.cpp +++ b/src/BiblioInfo.cpp @@ -1004,6 +1004,28 @@ void BiblioInfo::makeCitationLabels(Buffer const & buf) last = biit; } } + // Set the labels + it = cited_entries_.begin(); + for (; it != en; ++it) { + map<docstring, BibTeXInfo>::iterator const biit = bimap_.find(*it); + // this shouldn't happen, but... + if (biit == bimap_.end()) + // ...fail gracefully, anyway. + continue; + BibTeXInfo & entry = biit->second; + if (numbers) { + entry.label(entry.citeNumber()); + } else { + docstring const auth = entry.getAbbreviatedAuthor(buf, false); + // we do it this way so as to access the xref, if necessary + // note that this also gives us the modifier + docstring const year = getYear(*it, buf, true); + if (!auth.empty() && !year.empty()) + entry.label(auth + ' ' + year); + else + entry.label(entry.key()); + } + } } diff --git a/src/insets/InsetBibtex.cpp b/src/insets/InsetBibtex.cpp index 8a5e9fd..9c51355 100644 --- a/src/insets/InsetBibtex.cpp +++ b/src/insets/InsetBibtex.cpp @@ -933,8 +933,6 @@ int InsetBibtex::plaintext(odocstream & os, OutputParams const &) const BiblioInfo bibinfo = buffer().masterBibInfo(); bibinfo.makeCitationLabels(buffer()); vector<docstring> const & cites = bibinfo.citedEntries(); - CiteEngineType const engine_type = buffer().params().citeEngineType(); - bool const numbers = (engine_type == ENGINE_TYPE_NUMERICAL); docstring refoutput; docstring const reflabel = buffer().B_("References"); @@ -949,23 +947,7 @@ int InsetBibtex::plaintext(odocstream & os, OutputParams const &) const if (biit == bibinfo.end()) continue; BibTeXInfo const & entry = biit->second; - docstring citekey; - if (numbers) - citekey = entry.citeNumber(); - else { - docstring const auth = entry.getAbbreviatedAuthor(buffer(), false); - // we do it this way so as to access the xref, if necessary - // note that this also gives us the modifier - docstring const year = bibinfo.getYear(*vit, buffer(), true); - if (!auth.empty() && !year.empty()) - citekey = auth + ' ' + year; - } - if (citekey.empty()) { - citekey = entry.label(); - if (citekey.empty()) - citekey = entry.key(); - } - refoutput += "[" + citekey + "] "; + 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. @@ -983,8 +965,6 @@ docstring InsetBibtex::xhtml(XHTMLStream & xs, OutputParams const &) const { BiblioInfo const & bibinfo = buffer().masterBibInfo(); vector<docstring> const & cites = bibinfo.citedEntries(); - CiteEngineType const engine_type = buffer().params().citeEngineType(); - bool const numbers = (engine_type == ENGINE_TYPE_NUMERICAL); docstring const reflabel = buffer().B_("References"); @@ -1007,24 +987,8 @@ docstring InsetBibtex::xhtml(XHTMLStream & xs, OutputParams const &) const string const attr = "id='LyXCite-" + to_utf8(html::cleanAttr(entry.key())) + "'"; xs << html::CompTag("a", attr); - docstring citekey; - if (numbers) - citekey = entry.citeNumber(); - else { - docstring const auth = entry.getAbbreviatedAuthor(buffer(), false); - // we do it this way so as to access the xref, if necessary - // note that this also gives us the modifier - docstring const year = bibinfo.getYear(*vit, buffer(), true); - if (!auth.empty() && !year.empty()) - citekey = auth + ' ' + year; - } - if (citekey.empty()) { - citekey = entry.label(); - if (citekey.empty()) - citekey = entry.key(); - } xs << html::StartTag("span", "class='bibtexlabel'") - << citekey + << 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 commit f51636b547b87b710f6a22e067e94f96d41c740f Author: Julien Rioux <[email protected]> Date: Mon Feb 4 17:17:48 2013 +0100 Remove unused code. diff --git a/src/BiblioInfo.cpp b/src/BiblioInfo.cpp index 98d0cfe..bf718c7 100644 --- a/src/BiblioInfo.cpp +++ b/src/BiblioInfo.cpp @@ -625,14 +625,6 @@ docstring const BibTeXInfo::getLabel(BibTeXInfo const * const xref, { docstring loclabel; - /* - if (!is_bibtex_) { - BibTeXInfo::const_iterator it = find(from_ascii("ref")); - label_ = it->second; - return label_; - } - */ - int counter = 0; loclabel = expandFormat(format, xref, counter, buf, before, after, dialog, next); commit f94d77ae88950ff741a87c957a6362cdb48e9e50 Author: Julien Rioux <[email protected]> Date: Mon Feb 4 17:51:59 2013 +0100 Whitespace only. diff --git a/src/insets/InsetBibitem.cpp b/src/insets/InsetBibitem.cpp index f150d0d..a05b21d 100644 --- a/src/insets/InsetBibitem.cpp +++ b/src/insets/InsetBibitem.cpp @@ -340,7 +340,7 @@ docstring InsetBibitem::xhtml(XHTMLStream & xs, OutputParams const &) const // 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 = + string const attrs = "id='LyXCite-" + to_utf8(html::cleanAttr(getParam("key"))) + "'"; xs << html::CompTag("a", attrs); xs << html::StartTag("span", "class='bibitemlabel'"); diff --git a/src/insets/InsetBibtex.cpp b/src/insets/InsetBibtex.cpp index d0f7636..8a5e9fd 100644 --- a/src/insets/InsetBibtex.cpp +++ b/src/insets/InsetBibtex.cpp @@ -799,7 +799,7 @@ void InsetBibtex::parseBibTeXFiles() const docstring key; if (!readTypeOrKey(key, ifs, from_ascii(","), from_ascii("}"), keepCase)) { - lyxerr << "BibTeX Parser: Unable to read key for entry type:" << + lyxerr << "BibTeX Parser: Unable to read key for entry type:" << entryType << "." << std::endl; continue; } @@ -880,7 +880,7 @@ FileName InsetBibtex::getBibTeXPath(docstring const & filename, Buffer const & b file = FileName(makeAbsPath(texfile, buf.filePath())); return file; } - + bool InsetBibtex::addDatabase(docstring const & db) { @@ -1004,7 +1004,7 @@ docstring InsetBibtex::xhtml(XHTMLStream & xs, OutputParams const &) const xs << html::StartTag("div", "class='bibtexentry'"); // FIXME XHTML // The same name/id problem we have elsewhere. - string const attr = + string const attr = "id='LyXCite-" + to_utf8(html::cleanAttr(entry.key())) + "'"; xs << html::CompTag("a", attr); docstring citekey; ----------------------------------------------------------------------- Summary of changes: lib/layouts/jurabib.module | 4 ++- src/BiblioInfo.cpp | 38 +++++++++++++++++++++++++++------- src/Buffer.cpp | 7 ++++++ src/Buffer.h | 2 + src/insets/InsetBibitem.cpp | 2 +- src/insets/InsetBibtex.cpp | 46 ++++------------------------------------- src/insets/InsetCitation.cpp | 9 ++++++- src/output_plaintext.cpp | 1 + 8 files changed, 56 insertions(+), 53 deletions(-) hooks/post-receive -- The LyX Source Repository
