+
+/// Compound tag (no content, directly closed).
+class CTag {
+public:
+ ///
+ CTag(char const * const tag, std::string const & attr = "")
+ : tag_(tag), attr_(attr) {}
+ ///
+ char const * const tag_;
+ ///
+ std::string attr_;
+};
+
+
+/// 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 MathMLStream {
+public:
+ /// Builds a stream proxy for os; the MathML namespace is given by xmlns (supposed to be already defined elsewhere in the document).
+ explicit MathMLStream(odocstream & os, std::string const & xmlns = "", bool xmlMode = false);
+ ///
+ void cr();
+ ///
+ odocstream & os() { return os_; }
+ ///
+ int line() const { return line_; }
+ ///
+ int & tab() { return tab_; }
+ ///
+ friend MathMLStream & operator<<(MathMLStream &, char const *);
+ ///
+ void defer(docstring const &);
+ ///
+ void defer(std::string const &);
+ ///
+ docstring deferred() const;
+ ///
+ bool inText() const { return in_text_; }
+ ///
+ std::string xmlns() const { return xmlns_; }
+ ///
+ bool xmlMode() const { return xml_mode_; }
+ /// Returns the tag name prefixed by the name space if needed.
+ std::string namespacedTag(std::string const & tag) const {
+ return (xmlns().empty() ? "" : xmlns() + ":") + tag;
+ }
+private:
+ ///
+ void setTextMode(bool t) { in_text_ = t; }
+ ///
+ odocstream & os_;
+ ///
+ int tab_;
+ ///
+ int line_;
+ ///
+ bool in_text_;
+ ///
+ odocstringstream deferred_;
+ ///
+ std::string xmlns_;
+ ///
+ bool xml_mode_;
+ ///
+ friend class SetMode;
+};
+
+///
+MathMLStream & operator<<(MathMLStream &, MathAtom const &);
+///
+MathMLStream & operator<<(MathMLStream &, MathData const &);
+///
+MathMLStream & operator<<(MathMLStream &, docstring const &);
+///
+MathMLStream & operator<<(MathMLStream &, char const *);
+///
+MathMLStream & operator<<(MathMLStream &, char);
+///
+MathMLStream & operator<<(MathMLStream &, char_type);
+///
+MathMLStream & operator<<(MathMLStream &, MTag const &);
+///
+MathMLStream & operator<<(MathMLStream &, ETag const &);
+///
+MathMLStream & operator<<(MathMLStream &, CTag const &);
+
+
+/// A simpler version of ModeSpecifier, for MathML
+class SetMode {