]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetCitation.cpp
DocBook: escape IDs for InsetRef.
[lyx.git] / src / insets / InsetCitation.cpp
index 0335b9c771d9b21a3b8231803cdedebae657e232..a5253166d9f2dd5cae97a81f666493badb8a805c 100644 (file)
@@ -24,6 +24,7 @@
 #include "FuncStatus.h"
 #include "LaTeXFeatures.h"
 #include "output_xhtml.h"
+#include "output_docbook.h"
 #include "ParIterator.h"
 #include "texstream.h"
 #include "TocBackend.h"
@@ -545,19 +546,33 @@ static docstring const cleanupWhitespace(docstring const & citelist)
 }
 
 
-int InsetCitation::docbook(odocstream & os, OutputParams const &) const
+void InsetCitation::docbook(XMLStream & xs, OutputParams const &) const
 {
-       os << from_ascii("<citation>")
-          << cleanupWhitespace(getParam("key"))
-          << from_ascii("</citation>");
-       return 0;
+       if (getCmdName() == "nocite")
+               return;
+
+       // Split the different citations (on ","), so that one tag can be output for each of them.
+       string citations = to_utf8(xml::cleanID(getParam("key")));
+       if (citations.find(',') == string::npos) {
+               xs << xml::CompTag("biblioref", "endterm=\"" + citations + "\"");
+       } else {
+               size_t pos = 0;
+               while (pos != string::npos) {
+                       pos = citations.find(',');
+                       xs << xml::CompTag("biblioref", "endterm=\"" + citations.substr(0, pos) + "\"");
+                       citations.erase(0, pos + 1);
+
+                       if (pos != string::npos) {
+                               xs << ", "; 
+                       }
+               }
+       }
 }
 
 
 docstring InsetCitation::xhtml(XMLStream & xs, OutputParams const &) const
 {
-       string const & cmd = getCmdName();
-       if (cmd == "nocite")
+       if (getCmdName() == "nocite")
                return docstring();
 
        // have to output this raw, because generateLabel() will include tags
@@ -588,7 +603,7 @@ void InsetCitation::forOutliner(docstring & os, size_t const, bool const) const
 // engine, e.g. \cite[]{} for the basic engine.
 void InsetCitation::latex(otexstream & os, OutputParams const & runparams) const
 {
-       // When this is a child compiled on its own, we use the childs
+       // When this is a child compiled on its own, we use the children
        // own bibinfo, else the master's
        BiblioInfo const & bi = runparams.is_child
                        ? buffer().masterBibInfo() : buffer().bibInfo();