From d507a0b1475206c373b5fb02c8f984d0037b5e85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Matox?= Date: Mon, 25 Oct 2004 00:26:05 +0000 Subject: [PATCH] Escape content form inset index. (docbook) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9120 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 4 ++++ src/insets/ChangeLog | 4 ++++ src/insets/insetindex.C | 3 ++- src/sgml.C | 18 +++++++++++++++++- src/sgml.h | 3 +++ 5 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index f1a5b67bd1..d50b20253b 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2004-10-25 José Matos + + * sgml.[Ch] (escapeString): new function to escape all the string. + 2004-10-24 José Matos * paragraph.[Ch] (getFirstWord): new function to get the first diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index ad64556a71..bcc0012888 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,7 @@ +2004-10-24 Andreas Vox + + * insetindex.C (docbook): escape the index, to generate correct sgml. + 2004-10-23 José Matos * insettext.C (docbook): rearrange arguments, due to change in the upper diff --git a/src/insets/insetindex.C b/src/insets/insetindex.C index fa27b2440b..2cbee02a34 100644 --- a/src/insets/insetindex.C +++ b/src/insets/insetindex.C @@ -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 << "" << getContents() + os << "" << sgml::escapeString(getContents()) << ""; return 0; } diff --git a/src/sgml.C b/src/sgml.C index daab836cc1..0f2d28a31d 100644 --- a/src/sgml.C +++ b/src/sgml.C @@ -23,15 +23,17 @@ #include "support/std_ostream.h" #include "support/tostr.h" +#include + using lyx::support::subst; using std::make_pair; using std::ostream; +using std::ostringstream; using std::pair; using std::string; - namespace sgml { pair escapeChar(char c) @@ -94,6 +96,20 @@ pair 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) { diff --git a/src/sgml.h b/src/sgml.h index fb7b9cc63e..65eda14a1f 100644 --- a/src/sgml.h +++ b/src/sgml.h @@ -29,6 +29,9 @@ namespace sgml { */ std::pair 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,