}
// Always guard against unfortunate ligatures (!` ?`)
- if (prefixIs(qstr, "`"))
- qstr.insert(0, "{}");
+ if (prefixIs(qstr, "`")) {
+ char_type const lastchar = os.lastChar();
+ if (lastchar == '!' || lastchar == '?')
+ qstr.insert(0, "{}");
+ }
os << from_ascii(qstr);
}
protectspace_ = false;
}
os_.put(c);
+ lastchar_ = c;
if (c == '\n') {
texrow_.newline();
canbreakline_ = false;
{
if (ots.canBreakLine()) {
ots.os().put('\n');
+ ots.lastChar('\n');
ots.canBreakLine(false);
ots.texrow().newline();
}
{
if (ots.canBreakLine()) {
ots.os() << "%\n";
+ ots.lastChar('\n');
ots.canBreakLine(false);
ots.texrow().newline();
}
otexstream & operator<<(otexstream & ots, odocstream_manip pf)
{
ots.os() << pf;
- if (pf == static_cast<odocstream_manip>(endl))
+ if (pf == static_cast<odocstream_manip>(endl)) {
+ ots.lastChar('\n');
ots.texrow().newline();
+ }
return ots;
}
ots.protectSpace(false);
}
ots.os() << s;
+ ots.lastChar(s[len - 1]);
ots.texrow().newlines(count(s.begin(), s.end(), '\n'));
ots.canBreakLine(s[len - 1] != '\n');
return ots;
ots.protectSpace(false);
}
ots.os() << s;
+ ots.lastChar(s[len - 1]);
ots.texrow().newlines(count(s, s + len, '\n'));
ots.canBreakLine(s[len - 1] != '\n');
return ots;
ots.protectSpace(false);
}
ots.os() << c;
+ ots.lastChar(c);
if (c == '\n')
ots.texrow().newline();
ots.canBreakLine(c != '\n');
otexstream & operator<<(otexstream & ots, Type value)
{
ots.os() << value;
+ ots.lastChar(0);
ots.canBreakLine(true);
ots.protectSpace(false);
return ots;
they were iomanip's to ensure that the next output will start at the
beginning of a line. Using "breakln", a '\n' char will be output if needed,
while using "safebreakln", "%\n" will be output if needed.
+ The class also records the last output character.
*/
class otexstream {
///
otexstream(odocstream & os, TexRow & texrow)
: os_(os), texrow_(texrow),
- canbreakline_(false), protectspace_(false) {}
+ canbreakline_(false), protectspace_(false), lastchar_(0) {}
///
odocstream & os() { return os_; }
///
void protectSpace(bool protectspace) { protectspace_ = protectspace; }
///
bool protectSpace() const { return protectspace_; }
+ ///
+ void lastChar(char_type const & c) { lastchar_ = c; }
+ ///
+ char_type lastChar() const { return lastchar_; }
private:
///
odocstream & os_;
bool canbreakline_;
///
bool protectspace_;
+ ///
+ char_type lastchar_;
};
/// Helper structs for breaking a line