From: Richard Heck Date: Thu, 31 Dec 2009 19:49:29 +0000 (+0000) Subject: Fix MathML output for MathBox, as suggested in the FIXME. X-Git-Tag: 2.0.0~4642 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=19cd5f0e824b6ee6d03c6037c3db4527ecc8beeb;p=lyx.git Fix MathML output for MathBox, as suggested in the FIXME. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32711 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/development/HTML/HTML.notes b/development/HTML/HTML.notes index 7479623387..0f863b47bc 100644 --- a/development/HTML/HTML.notes +++ b/development/HTML/HTML.notes @@ -54,7 +54,6 @@ Math isues, and not all the insets work. Here are the ones I know still need work: - AMSArray - Array - - Box - Cases - Diff: Code exists, but I do not know if it is right. - Binom (in Frac): None of these tags exist in MathML 2.0. We'll diff --git a/src/mathed/InsetMathBox.cpp b/src/mathed/InsetMathBox.cpp index d432794fc0..8aba8d80fc 100644 --- a/src/mathed/InsetMathBox.cpp +++ b/src/mathed/InsetMathBox.cpp @@ -54,12 +54,8 @@ void InsetMathBox::normalize(NormalStream & os) const void InsetMathBox::mathmlize(MathStream & ms) const { - // FIXME This doesn't actually work yet. We need to be able to signal - // that we are in text mode and then just call ms << cell(0). So we - // need something like ModeSpecifier for MathStream. - ms << MTag("mtext"); - ms.os() << cell(0); - ms << ETag("mtext"); + SetMode textmode(ms, true); + ms << cell(0); } diff --git a/src/mathed/MathStream.cpp b/src/mathed/MathStream.cpp index 81a89dc6d3..ffc91c4f42 100644 --- a/src/mathed/MathStream.cpp +++ b/src/mathed/MathStream.cpp @@ -337,22 +337,35 @@ MathStream & operator<<(MathStream & ms, docstring const & s) } +SetMode::SetMode(MathStream & os, bool text) + : os_(os) +{ + init(text, from_ascii("")); +} + + SetMode::SetMode(MathStream & os, bool text, docstring attrs) - : os_(os) + : os_(os) { - was_text_ = os.inText(); + init(text, attrs); +} + + +void SetMode::init(bool text, docstring attrs) +{ + was_text_ = os_.inText(); if (was_text_) - os << ""; + os_ << ""; if (text) { - os.setTextMode(); - os << ""; + os_ << " " << attrs; + os_ << ">"; } else { if (!attrs.empty()) - os << ""; - os.setMathMode(); + os_ << ""; + os_.setMathMode(); } } diff --git a/src/mathed/MathStream.h b/src/mathed/MathStream.h index df97ce303a..51760a33dd 100644 --- a/src/mathed/MathStream.h +++ b/src/mathed/MathStream.h @@ -263,13 +263,13 @@ public: void defer(std::string const &); /// docstring deferred() const; + /// + bool inText() const { return in_text_; } +private: /// void setTextMode() { in_text_ = true; } /// void setMathMode() { in_text_ = false; } - /// - bool inText() const { return in_text_; } -private: /// odocstream & os_; /// @@ -282,6 +282,8 @@ private: bool in_text_; /// odocstringstream deferred_; + /// + friend class SetMode; }; /// @@ -307,11 +309,13 @@ class SetMode { public: /// explicit SetMode(MathStream & os, bool text, docstring attrs); - // not clear yet precisely what we need... - // explicit SetMode(MathStream & os, bool text); + /// + explicit SetMode(MathStream & os, bool text); /// ~SetMode(); private: + /// + void init(bool, docstring); /// MathStream & os_; ///