From c6bf3382075de6134c541826d30de0159a0f4eca Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Matox?= Date: Thu, 21 Oct 2004 22:39:20 +0000 Subject: [PATCH] Export Inset Cite (docbook) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9100 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/ChangeLog | 5 +++++ src/insets/insetcite.C | 43 +++++++++++++++++++++++++++++------------- src/insets/insetcite.h | 3 +++ 3 files changed, 38 insertions(+), 13 deletions(-) diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 11db1ce162..37c93c9ac1 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,8 @@ +2004-10-17 Andreas Vox + + * insetcite.[hC] (docbook, latex, cleanupWhitespace): implementing + DocBook output for this inset ( content ) + 2004-10-05 Andreas Vox * insetgraphics.C (docbook) : using mediaobject for XML; diff --git a/src/insets/insetcite.C b/src/insets/insetcite.C index accd92cedd..7407c78763 100644 --- a/src/insets/insetcite.C +++ b/src/insets/insetcite.C @@ -324,6 +324,35 @@ int InsetCitation::plaintext(Buffer const & buffer, ostream & os, OutputParams c } +namespace { + +string const cleanupWhitespace(string const & citelist) +{ + string::const_iterator it = citelist.begin(); + string::const_iterator end = citelist.end(); + // Paranoia check: make sure that there is no whitespace in here + // -- at least not behind commas or at the beginning + string result; + char last = ','; + for (; it != end; ++it) { + if (*it != ' ') + last = *it; + if (*it != ' ' || last != ',') + result += *it; + } + return result; +} + +// end anon namyspace +} + +int InsetCitation::docbook(Buffer const &, ostream & os, OutputParams const &) const +{ + os << "" << cleanupWhitespace(getContents()) << ""; + return 0; +} + + // Have to overwrite the default InsetCommand method in order to check that // the \cite command is valid. Eg, the user has natbib enabled, inputs some // citations and then changes his mind, turning natbib support off. The output @@ -344,19 +373,7 @@ int InsetCitation::latex(Buffer const & buffer, ostream & os, else if (!after.empty()) os << '[' << after << ']'; - string::const_iterator it = getContents().begin(); - string::const_iterator end = getContents().end(); - // Paranoia check: make sure that there is no whitespace in here - string content; - char last = ','; - for (; it != end; ++it) { - if (*it != ' ') - last = *it; - if (*it != ' ' || last != ',') - content += *it; - } - - os << '{' << content << '}'; + os << '{' << cleanupWhitespace(getContents()) << '}'; return 0; } diff --git a/src/insets/insetcite.h b/src/insets/insetcite.h index 6d425985c4..fd90c887fc 100644 --- a/src/insets/insetcite.h +++ b/src/insets/insetcite.h @@ -40,6 +40,9 @@ public: int latex(Buffer const &, std::ostream &, OutputParams const &) const; /// + int docbook(Buffer const &, std::ostream &, + OutputParams const &) const; + /// void validate(LaTeXFeatures &) const; private: -- 2.39.2