/////////////////////////////////////////////////////////////////
-WriteStream & operator<<(WriteStream & ws, docstring const & s)
+TeXMathStream & operator<<(TeXMathStream & ws, docstring const & s)
{
// Skip leading '\n' if we had already output a newline char
size_t const first =
} 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;
}
-WriteStream::WriteStream(otexrowstream & os, bool fragile, bool latex,
- OutputType output, Encoding const * encoding)
+TeXMathStream::TeXMathStream(otexrowstream & os, bool fragile, bool latex,
+ OutputType output, Encoding const * encoding)
: os_(os), fragile_(fragile), latex_(latex),
output_(output), encoding_(encoding)
{}
-WriteStream::~WriteStream()
+TeXMathStream::~TeXMathStream()
{
if (pendingbrace_)
os_ << '}';
}
-void WriteStream::addlines(unsigned int n)
+void TeXMathStream::addlines(unsigned int n)
{
line_ += n;
}
-void WriteStream::pendingSpace(bool how)
+void TeXMathStream::pendingSpace(bool space)
{
- pendingspace_ = how;
+ pendingspace_ = space;
+ if (!space)
+ usebraces_ = false;
}
-void WriteStream::pendingBrace(bool brace)
+void TeXMathStream::useBraces(bool braces)
+{
+ usebraces_ = braces;
+}
+
+
+void TeXMathStream::pendingBrace(bool brace)
{
pendingbrace_ = brace;
}
-void WriteStream::textMode(bool textmode)
+void TeXMathStream::textMode(bool textmode)
{
textmode_ = textmode;
}
-void WriteStream::lockedMode(bool locked)
+void TeXMathStream::lockedMode(bool locked)
{
locked_ = locked;
}
-void WriteStream::asciiOnly(bool ascii)
+void TeXMathStream::asciiOnly(bool ascii)
{
ascii_ = ascii;
}
-Changer WriteStream::changeRowEntry(TexRow::RowEntry entry)
+Changer TeXMathStream::changeRowEntry(TexRow::RowEntry entry)
{
return changeVar(row_entry_, entry);
}
-bool WriteStream::startOuterRow()
+bool TeXMathStream::startOuterRow()
{
if (TexRow::isNone(row_entry_))
return false;
}
-WriteStream & operator<<(WriteStream & ws, MathAtom const & at)
+TeXMathStream & operator<<(TeXMathStream & ws, MathAtom const & at)
{
at->write(ws);
return ws;
}
-WriteStream & operator<<(WriteStream & ws, MathData const & ar)
+TeXMathStream & operator<<(TeXMathStream & ws, MathData const & ar)
{
write(ar, ws);
return ws;
}
-WriteStream & operator<<(WriteStream & ws, char const * s)
+TeXMathStream & operator<<(TeXMathStream & ws, char const * s)
{
ws << from_utf8(s);
return ws;
}
-WriteStream & operator<<(WriteStream & ws, char c)
+TeXMathStream & operator<<(TeXMathStream & ws, char c)
{
if (c == '\n' && !ws.canBreakLine())
return ws;
} 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')
}
-WriteStream & operator<<(WriteStream & ws, int i)
+TeXMathStream & operator<<(TeXMathStream & ws, int i)
{
if (ws.pendingBrace()) {
ws.os() << '}';
}
-WriteStream & operator<<(WriteStream & ws, unsigned int i)
+TeXMathStream & operator<<(TeXMathStream & ws, unsigned int i)
{
if (ws.pendingBrace()) {
ws.os() << '}';