From 3de92f551a4e7af6081478e20e04052268771364 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Thu, 11 Jun 2009 21:04:15 +0000 Subject: [PATCH] Get XHTML output for InsetCitation working, at least in a primitive way. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30049 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/InsetCitation.cpp | 45 ++++++++++++++++++++++++++++++++++-- src/insets/InsetCitation.h | 2 ++ 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/src/insets/InsetCitation.cpp b/src/insets/InsetCitation.cpp index 7b1dbc5a49..25038a7e61 100644 --- a/src/insets/InsetCitation.cpp +++ b/src/insets/InsetCitation.cpp @@ -417,8 +417,8 @@ docstring InsetCitation::toolTip(BufferView const & bv, int, int) const docstring InsetCitation::generateLabel() const { - docstring const before = getParam("before"); - docstring const after = getParam("after"); + docstring const & before = getParam("before"); + docstring const & after = getParam("after"); docstring label; CiteEngine const engine = buffer().params().citeEngine(); @@ -504,6 +504,47 @@ int InsetCitation::docbook(odocstream & os, OutputParams const &) const } +int InsetCitation::xhtml(odocstream & os, OutputParams const &) const +{ + BiblioInfo const & bi = buffer().masterBibInfo(); + docstring const & keyList = getParam("key"); + if (keyList.empty()) + return 0; + + // FIXME We shuld do a better job outputing different things for the + // different citation styles. For now, we use square brackets for every + // case. + os << '['; + docstring const & before = getParam("before"); + if (!before.empty()) + os << before << " "; + + vector keys = getVectorFromString(keyList); + vector::const_iterator it = keys.begin(); + vector::const_iterator en = keys.end(); + bool first = true; + for (; it != en; ++it) { + BiblioInfo::const_iterator const bt = bi.find(*it); + if (bt == bi.end()) + continue; + BibTeXInfo const & bibinfo = bt->second; + if (!first) { + os << ", "; + first = false; + } + docstring const & label = bibinfo.label(); + docstring const & target = label.empty() ? *it : label; + os << "" << target << ""; + } + + docstring const & after = getParam("after"); + if (!after.empty()) + os << ", " << after; + os << "]\n"; + return 0; +} + + void InsetCitation::tocString(odocstream & os) const { plaintext(os, OutputParams(0)); diff --git a/src/insets/InsetCitation.h b/src/insets/InsetCitation.h index 4567077a42..04cc480eb5 100644 --- a/src/insets/InsetCitation.h +++ b/src/insets/InsetCitation.h @@ -49,6 +49,8 @@ public: int plaintext(odocstream &, OutputParams const &) const; /// int docbook(odocstream &, OutputParams const &) const; + /// + int xhtml(odocstream &, OutputParams const &) const; /// the string that is passed to the TOC void tocString(odocstream &) const; /// -- 2.39.2