Is the attached OK ? I assumed that JMarc was right and that this is a
bug in textcolor, which therefore needs special handling.
Vincent
Index: src/Paragraph.cpp
===================================================================
--- src/Paragraph.cpp (revision 30756)
+++ src/Paragraph.cpp (working copy)
@@ -2081,9 +2081,14 @@
running_font = font;
open_font = true;
docstring fontchange = ods.str();
+ docstring const last_modifier = rsplit(fontchange,
'\\');
+ // check whether the fontchange ends with a \\textcolor
+ // modifier and the text starts with a space (bug 4473)
+ 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
Index: src/support/lstrings.cpp
===================================================================
--- src/support/lstrings.cpp (revision 30748)
+++ src/support/lstrings.cpp (working copy)
@@ -899,6 +899,16 @@
}
+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',
Index: src/support/lstrings.h
===================================================================
--- src/support/lstrings.h (revision 30748)
+++ src/support/lstrings.h (working copy)
@@ -221,6 +221,7 @@
/// 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.