]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/MathStream.cpp
We only support gcc >= 4.9.
[lyx.git] / src / mathed / MathStream.cpp
index 51ac98486795718acdcf3c7c3e75ac52a0444425..e14e850e1805fa7f8a85471f18ba283e7128871b 100644 (file)
@@ -106,9 +106,15 @@ TeXMathStream & operator<<(TeXMathStream & ws, docstring const & s)
        } else if (ws.pendingSpace()) {
                if (isAlphaASCII(s[first]))
                        ws.os() << ' ';
+               else if (s[first] == '[' && ws.useBraces())
+                       ws.os() << "{}";
                else if (s[first] == ' ' && ws.textMode())
                        ws.os() << '\\';
                ws.pendingSpace(false);
+       } else if (ws.useBraces()) {
+               if (s[first] == '\'')
+                       ws.os() << "{}";
+               ws.useBraces(false);
        }
        ws.os() << s.substr(first);
        int lf = 0;
@@ -148,9 +154,17 @@ void TeXMathStream::addlines(unsigned int n)
 }
 
 
-void TeXMathStream::pendingSpace(bool how)
+void TeXMathStream::pendingSpace(bool space)
 {
-       pendingspace_ = how;
+       pendingspace_ = space;
+       if (!space)
+               usebraces_ = false;
+}
+
+
+void TeXMathStream::useBraces(bool braces)
+{
+       usebraces_ = braces;
 }
 
 
@@ -226,9 +240,15 @@ TeXMathStream & operator<<(TeXMathStream & ws, char c)
        } else if (ws.pendingSpace()) {
                if (isAlphaASCII(c))
                        ws.os() << ' ';
+               else if (c == '[' && ws.useBraces())
+                       ws.os() << "{}";
                else if (c == ' ' && ws.textMode())
                        ws.os() << '\\';
                ws.pendingSpace(false);
+       } else if (ws.useBraces()) {
+               if (c == '\'')
+                       ws.os() << "{}";
+               ws.useBraces(false);
        }
        ws.os() << c;
        if (c == '\n')