]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/MathStream.cpp
typo
[lyx.git] / src / mathed / MathStream.cpp
index 51ac98486795718acdcf3c7c3e75ac52a0444425..a6d160ce32aaf978ec61d3fcf5c4cf8e2054d0a5 100644 (file)
@@ -26,6 +26,7 @@
 #include <algorithm>
 #include <cstring>
 #include <ostream>
+#include <FontInfo.h>
 
 using namespace std;
 
@@ -106,9 +107,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 +155,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 +241,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')
@@ -269,7 +290,12 @@ TeXMathStream & operator<<(TeXMathStream & ws, unsigned int i)
 
 MathMLStream::MathMLStream(odocstream & os, std::string const & xmlns, bool xmlMode)
        : os_(os), tab_(0), line_(0), in_text_(false), xmlns_(xmlns), xml_mode_(xmlMode)
-{}
+{
+       if (in_text_)
+               font_math_style_ = TEXT_STYLE;
+       else
+               font_math_style_ = DISPLAY_STYLE;
+}
 
 
 void MathMLStream::cr()
@@ -345,6 +371,17 @@ MathMLStream & operator<<(MathMLStream & ms, MTag const & t)
 }
 
 
+MathMLStream & operator<<(MathMLStream & ms, MTagInline const & t)
+{
+       ms.cr();
+       ms.os() << '<' << from_ascii(ms.namespacedTag(t.tag_));
+       if (!t.attr_.empty())
+               ms.os() << " " << from_ascii(t.attr_);
+       ms << ">";
+       return ms;
+}
+
+
 MathMLStream & operator<<(MathMLStream & ms, ETag const & t)
 {
        ms.cr();
@@ -355,6 +392,13 @@ MathMLStream & operator<<(MathMLStream & ms, ETag const & t)
 }
 
 
+MathMLStream & operator<<(MathMLStream & ms, ETagInline const & t)
+{
+       ms.os() << "</" << from_ascii(ms.namespacedTag(t.tag_)) << ">";
+       return ms;
+}
+
+
 MathMLStream & operator<<(MathMLStream & ms, CTag const & t)
 {
        ms.cr();