mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Fix sgml::escapeChar and sgml::escapeString to return docstring.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15444 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
2c0d4b31ee
commit
5d6963b0ca
@ -46,9 +46,8 @@ docstring const InsetIndex::getScreenLabel(Buffer const &) const
|
||||
int InsetIndex::docbook(Buffer const &, odocstream & os,
|
||||
OutputParams const &) const
|
||||
{
|
||||
// FIXME UNICODE
|
||||
os << "<indexterm><primary>"
|
||||
<< from_ascii(sgml::escapeString(lyx::to_ascii(getParam("name"))))
|
||||
<< sgml::escapeString(getParam("name"))
|
||||
<< "</primary></indexterm>";
|
||||
return 0;
|
||||
}
|
||||
|
@ -1179,14 +1179,8 @@ pos_type Paragraph::getFirstWord(Buffer const & buf, odocstream & os, OutputPara
|
||||
value_type c = getChar(i);
|
||||
if (c == ' ')
|
||||
break;
|
||||
bool ws;
|
||||
string str;
|
||||
// FIXME UNICODE
|
||||
// sgml::escapeChar takes a char, not lyx::char_type
|
||||
boost::tie(ws, str) = sgml::escapeChar(c);
|
||||
// FIXME UNICODE
|
||||
os << from_ascii(str);
|
||||
}
|
||||
os << sgml::escapeChar(c);
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
@ -1244,17 +1238,12 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf,
|
||||
inset->docbook(buf, os, runparams);
|
||||
} else {
|
||||
value_type c = getChar(i);
|
||||
bool ws;
|
||||
string str;
|
||||
// FIXME UNICODE
|
||||
// sgml::escapeChar takes a char, not lyx::char_type
|
||||
boost::tie(ws, str) = sgml::escapeChar(c);
|
||||
|
||||
if (style->pass_thru)
|
||||
os.put(c);
|
||||
else
|
||||
// FIXME UNICODE
|
||||
os << from_ascii(str);
|
||||
os << sgml::escapeChar(c);
|
||||
}
|
||||
font_old = font;
|
||||
}
|
||||
|
56
src/sgml.C
56
src/sgml.C
@ -20,12 +20,11 @@
|
||||
#include "outputparams.h"
|
||||
#include "paragraph.h"
|
||||
|
||||
#include "support/docstring.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "support/std_ostream.h"
|
||||
#include "support/convert.h"
|
||||
|
||||
#include <boost/tuple/tuple.hpp>
|
||||
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
|
||||
@ -34,82 +33,73 @@ namespace lyx {
|
||||
|
||||
using support::subst;
|
||||
|
||||
using std::make_pair;
|
||||
using std::map;
|
||||
using std::ostream;
|
||||
using std::ostringstream;
|
||||
using std::pair;
|
||||
using std::string;
|
||||
|
||||
pair<bool, string> sgml::escapeChar(char c)
|
||||
docstring sgml::escapeChar(char_type c)
|
||||
{
|
||||
string str;
|
||||
|
||||
docstring str;
|
||||
switch (c) {
|
||||
case ' ':
|
||||
return make_pair(true, string(" "));
|
||||
break;
|
||||
case '\0': // Ignore :-)
|
||||
str.erase();
|
||||
str += " ";
|
||||
break;
|
||||
case '&':
|
||||
str = "&";
|
||||
str += "&";
|
||||
break;
|
||||
case '<':
|
||||
str = "<";
|
||||
str += "<";
|
||||
break;
|
||||
case '>':
|
||||
str = ">";
|
||||
str += ">";
|
||||
break;
|
||||
#if 0
|
||||
case '$':
|
||||
str = "$";
|
||||
str += "$";
|
||||
break;
|
||||
case '#':
|
||||
str = "#";
|
||||
str += "#";
|
||||
break;
|
||||
case '%':
|
||||
str = "%";
|
||||
str += "%";
|
||||
break;
|
||||
case '[':
|
||||
str = "[";
|
||||
str += "[";
|
||||
break;
|
||||
case ']':
|
||||
str = "]";
|
||||
str += "]";
|
||||
break;
|
||||
case '{':
|
||||
str = "{";
|
||||
str += "{";
|
||||
break;
|
||||
case '}':
|
||||
str = "}";
|
||||
str += "}";
|
||||
break;
|
||||
case '~':
|
||||
str = "˜";
|
||||
str += "˜";
|
||||
break;
|
||||
case '"':
|
||||
str = """;
|
||||
str += """;
|
||||
break;
|
||||
case '\\':
|
||||
str = "\";
|
||||
str += "\";
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
str = c;
|
||||
str += c;
|
||||
break;
|
||||
}
|
||||
return make_pair(false, str);
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
string sgml::escapeString(string const & raw)
|
||||
docstring sgml::escapeString(docstring const & raw)
|
||||
{
|
||||
ostringstream bin;
|
||||
odocstringstream bin;
|
||||
|
||||
for(string::size_type i = 0; i < raw.size(); ++i) {
|
||||
bool ws;
|
||||
string str;
|
||||
boost::tie(ws, str) = sgml::escapeChar(raw[i]);
|
||||
bin << str;
|
||||
for(docstring::size_type i = 0; i < raw.size(); ++i) {
|
||||
bin << sgml::escapeChar(raw[i]);
|
||||
}
|
||||
return bin.str();
|
||||
}
|
||||
|
@ -31,13 +31,12 @@ namespace sgml {
|
||||
|
||||
/**
|
||||
* Escape the given character, if necessary,
|
||||
* to an SGML entity. Returns true
|
||||
* if it was a whitespace character.
|
||||
* to an SGML entity.
|
||||
*/
|
||||
std::pair<bool, std::string> escapeChar(char c);
|
||||
docstring escapeChar(char_type c);
|
||||
|
||||
/// Escape a word instead of a single character
|
||||
std::string escapeString(std::string const & raw);
|
||||
docstring escapeString(docstring const & raw);
|
||||
|
||||
/// replaces illegal characters from SGML/XML ID attributes
|
||||
std::string cleanID(Buffer const & buf, OutputParams const & runparams,
|
||||
|
Loading…
Reference in New Issue
Block a user