Fix bug #4473: Incorrect LaTeX output for inter-word spaces.

This is a hack necessary because \\textcolor is a bit buggy.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30773 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Vincent van Ravesteijn 2009-07-25 10:44:36 +00:00
parent 35db143564
commit 504bc83a64
3 changed files with 17 additions and 1 deletions

View File

@ -2081,9 +2081,14 @@ bool Paragraph::latex(BufferParams const & bparams,
running_font = font;
open_font = true;
docstring fontchange = ods.str();
// check whether the fontchange ends with a \\textcolor
// modifier and the text starts with a space (bug 4473)
docstring const last_modifier = rsplit(fontchange, '\\');
if (prefixIs(last_modifier, from_ascii("textcolor")) && c == ' ')
os << fontchange << from_ascii("{}");
// check if the fontchange ends with a trailing blank
// (like "\small " (see bug 3382)
if (suffixIs(fontchange, ' ') && c == ' ')
else if (suffixIs(fontchange, ' ') && c == ' ')
os << fontchange.substr(0, fontchange.size() - 1)
<< from_ascii("{}");
else

View File

@ -899,6 +899,16 @@ string const rsplit(string const & a, string & piece, char delim)
}
docstring const rsplit(docstring const & a, char_type delim)
{
docstring tmp;
size_t i = a.rfind(delim);
if (i != string::npos)
tmp = a.substr(i + 1);
return tmp;
}
docstring const escape(docstring const & lab)
{
char_type hexdigit[16] = { '0', '1', '2', '3', '4', '5', '6', '7',

View File

@ -221,6 +221,7 @@ std::string const split(std::string const & a, char delim);
/// Same as split but uses the last delim.
std::string const rsplit(std::string const & a, std::string & piece, char delim);
docstring const rsplit(docstring const & a, char_type delim);
/// Escapes non ASCII chars and other problematic characters that cause
/// problems in latex labels.