]> git.lyx.org Git - features.git/commitdiff
Escape content form inset index. (docbook)
authorJosé Matox <jamatos@lyx.org>
Mon, 25 Oct 2004 00:26:05 +0000 (00:26 +0000)
committerJosé Matox <jamatos@lyx.org>
Mon, 25 Oct 2004 00:26:05 +0000 (00:26 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9120 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/insets/ChangeLog
src/insets/insetindex.C
src/sgml.C
src/sgml.h

index f1a5b67bd190623ddbd3f1186d274798d9f1b8ae..d50b20253b79538cb2aa9c021d9499b72d0f80eb 100644 (file)
@@ -1,3 +1,7 @@
+2004-10-25  José Matos  <jamatos@lyx.org>
+
+       * sgml.[Ch] (escapeString): new function to escape all the string.
+
 2004-10-24  José Matos  <jamatos@lyx.org>
 
        * paragraph.[Ch] (getFirstWord): new function to get the first
index ad64556a71724b21e2d6884db1257489f6ffaa5c..bcc0012888963786f93edd0256672f23ef59698c 100644 (file)
@@ -1,3 +1,7 @@
+2004-10-24  Andreas Vox  <vox@isp.uni-luebeck.de>
+
+       * insetindex.C (docbook): escape the index, to generate correct sgml.
+
 2004-10-23  José Matos  <jamatos@lyx.org>
 
        * insettext.C (docbook): rearrange arguments, due to change in the upper
index fa27b2440b5076d7bf40a13efa82e3e22aaf35c7..2cbee02a34398915fd25780bab46be2344be565c 100644 (file)
@@ -16,6 +16,7 @@
 #include "gettext.h"
 #include "LaTeXFeatures.h"
 #include "metricsinfo.h"
+#include "sgml.h"
 
 #include "support/std_ostream.h"
 
@@ -42,7 +43,7 @@ string const InsetIndex::getScreenLabel(Buffer const &) const
 int InsetIndex::docbook(Buffer const &, ostream & os,
                        OutputParams const &) const
 {
-       os << "<indexterm><primary>" << getContents()
+       os << "<indexterm><primary>" << sgml::escapeString(getContents())
           << "</primary></indexterm>";
        return 0;
 }
index daab836cc107259090b6517b6e6db2cf57139e59..0f2d28a31d3f7586e6036330ad67631ac36462a2 100644 (file)
 #include "support/std_ostream.h"
 #include "support/tostr.h"
 
+#include <sstream>
+
 using lyx::support::subst;
 
 using std::make_pair;
 
 using std::ostream;
+using std::ostringstream;
 using std::pair;
 using std::string;
 
-
 namespace sgml {
 
 pair<bool, string> escapeChar(char c)
@@ -94,6 +96,20 @@ pair<bool, string> escapeChar(char c)
 }
 
 
+string escapeString(string const & raw)
+{
+       ostringstream bin;
+
+       for(int i=0; i < raw.size(); ++i) {
+               bool ws;
+               string str;
+               boost::tie(ws, str) = sgml::escapeChar(raw[i]);
+               bin << str;
+       }
+       return bin.str();
+}
+
+
 int openTag(Buffer const & buf, ostream & os, Paragraph::depth_type depth,
            bool mixcont, string const & name, string const & param)
 {
index fb7b9cc63efb76e2bc31328a0ace8a9c38db79ef..65eda14a1f9d170c88b9a108e073c1295d18ced6 100644 (file)
@@ -29,6 +29,9 @@ namespace sgml {
  */
 std::pair<bool, std::string> escapeChar(char c);
 
+/// Escape a word instead of a single character
+std::string escapeString(std::string const & raw);
+
 /// Opens tag
 int openTag(Buffer const & buf, std::ostream & os, lyx::depth_type depth,
            bool mixcont, std::string const & name,