bool & firstitem() { return firstitem_; }
///
void addlines(unsigned int);
+ /// record whether we can write an immediately following newline char
+ void canBreakLine(bool breakline) { canbreakline_ = breakline; }
+ /// tell whether we can write an immediately following newline char
+ bool canBreakLine() const { return canbreakline_; }
/// writes space if next thing is isalpha()
void pendingSpace(bool how);
/// writes space if next thing is isalpha()
bool locked_;
/// should we use only ascii chars when producing latex code?
bool ascii_;
+ /// are we allowed to output an immediately following newline?
+ bool canbreakline_;
///
int line_;
///
};
+/// Throw MathExportException to signal that the attempt to export
+/// some math in the current format did not succeed. E.g., we can't
+/// export xymatrix as MathML, so that will throw, and we'll fall back
+/// to images.
+class MathExportException : public std::exception {};
+
+
class MathStream {
public:
///
bool inText() const { return in_text_; }
private:
///
- void setTextMode() { in_text_ = true; }
- ///
- void setMathMode() { in_text_ = false; }
+ void setTextMode(bool t) { in_text_ = t; }
///
odocstream & os_;
///
///
int line_;
///
- char lastchar_;
- ///
bool in_text_;
///
odocstringstream deferred_;
/// A simpler version of ModeSpecifier, for MathML
-// FIXME There are still problems here with nesting, at least
-// potentially. The problem is that true nesting of text mode isn't
-// actually possible. I.e., we can't have:
-// <mtext><mtext></mtext></mtext>
-// So we have to have:
-// <mtext></mtext><mtext></mtext><mtext></mtext>
-// instead, where the last is really a continuation of the first.
-// We'll need some kind of stack to remember all that.
class SetMode {
public:
- ///
- explicit SetMode(MathStream & os, bool text, docstring attrs);
///
explicit SetMode(MathStream & os, bool text);
///
~SetMode();
private:
- ///
- void init(bool, docstring);
///
MathStream & os_;
///
- bool opened_;
+ bool was_text_;
+};
+
+
+class HtmlStream {
+public:
+ ///
+ explicit HtmlStream(odocstream & os);
+ ///
+ void cr();
+ ///
+ odocstream & os() { return os_; }
+ ///
+ int line() const { return line_; }
+ ///
+ int & tab() { return tab_; }
+ ///
+ friend HtmlStream & operator<<(HtmlStream &, char const *);
+ ///
+ void defer(docstring const &);
+ ///
+ void defer(std::string const &);
+ ///
+ docstring deferred() const;
+ ///
+ bool inText() const { return in_text_; }
+private:
+ ///
+ void setTextMode(bool t) { in_text_ = t; }
+ ///
+ odocstream & os_;
+ ///
+ int tab_;
+ ///
+ int line_;
+ ///
+ bool in_text_;
+ ///
+ odocstringstream deferred_;
+ ///
+ friend class SetHTMLMode;
+};
+
+///
+HtmlStream & operator<<(HtmlStream &, MathAtom const &);
+///
+HtmlStream & operator<<(HtmlStream &, MathData const &);
+///
+HtmlStream & operator<<(HtmlStream &, docstring const &);
+///
+HtmlStream & operator<<(HtmlStream &, char const *);
+///
+HtmlStream & operator<<(HtmlStream &, char);
+///
+HtmlStream & operator<<(HtmlStream &, char_type);
+///
+HtmlStream & operator<<(HtmlStream &, MTag const &);
+///
+HtmlStream & operator<<(HtmlStream &, ETag const &);
+
+
+class SetHTMLMode {
+public:
+ ///
+ explicit SetHTMLMode(HtmlStream & os, bool text);
+ ///
+ ~SetHTMLMode();
+private:
+ ///
+ HtmlStream & os_;
///
bool was_text_;
};