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: