]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_hullinset.C
revert Buffer LyxText->InsetText commit
[lyx.git] / src / mathed / math_hullinset.C
index 781cfd08b42a997053d2dd6283372183529fefa5..3f46a091c1a015ea127865f8455b4d6611da6be0 100644 (file)
@@ -27,6 +27,7 @@
 #include "LaTeXFeatures.h"
 #include "LColor.h"
 #include "lyxrc.h"
+#include "outputparams.h"
 #include "textpainter.h"
 
 #include "frontends/Alert.h"
 #include "support/std_sstream.h"
 
 
-using lyx::support::trim;
-
 using std::endl;
 using std::max;
-
 using std::string;
+using std::ostream;
 using std::auto_ptr;
 using std::istringstream;
+using std::ostream;
 using std::ostringstream;
 using std::pair;
+using std::swap;
+using std::vector;
 
 
 namespace {
@@ -109,6 +111,7 @@ namespace {
 } // end anon namespace
 
 
+
 MathHullInset::MathHullInset()
        : MathGridInset(1, 1), type_("none"), nonum_(1), label_(1)
 {
@@ -196,11 +199,11 @@ void MathHullInset::metrics(MetricsInfo & mi, Dimension & dim) const
        StyleChanger dummy2(mi.base, display() ? LM_ST_DISPLAY : LM_ST_TEXT);
 
        // let the cells adjust themselves
-       MathGridInset::metrics(mi);
+       MathGridInset::metrics(mi, dim);
 
        if (display()) {
-               dim_.asc += 12;
-               dim_.des += 12;
+               dim.asc += 12;
+               dim.des += 12;
        }
 
        if (numberedType()) {
@@ -210,19 +213,19 @@ void MathHullInset::metrics(MetricsInfo & mi, Dimension & dim) const
                        l = max(l, mathed_string_width(mi.base.font, nicelabel(row)));
 
                if (l)
-                       dim_.wid += 30 + l;
+                       dim.wid += 30 + l;
        }
 
        // make it at least as high as the current font
        int asc = 0;
        int des = 0;
        math_font_max_dim(mi.base.font, asc, des);
-       dim_.asc = max(dim_.asc, asc);
-       dim_.des = max(dim_.des, des);
+       dim.asc = max(dim.asc, asc);
+       dim.des = max(dim.des, des);
 
        // for markers
-       metricsMarkers2();
-       dim = dim_;
+       metricsMarkers2(dim);
+       dim_ = dim;
 }
 
 
@@ -319,8 +322,7 @@ bool MathHullInset::display() const
 }
 
 
-void MathHullInset::getLabelList(Buffer const &,
-                                std::vector<string> & labels) const
+void MathHullInset::getLabelList(Buffer const &, vector<string> & labels) const
 {
        for (row_type row = 0; row < nrows(); ++row)
                if (!label_[row].empty() && nonum_[row] != 1)
@@ -449,8 +451,8 @@ void MathHullInset::swapRow(row_type row)
                return;
        if (row + 1 == nrows())
                --row;
-       std::swap(nonum_[row], nonum_[row + 1]);
-       std::swap(label_[row], label_[row + 1]);
+       swap(nonum_[row], nonum_[row + 1]);
+       swap(label_[row], label_[row + 1]);
        MathGridInset::swapRow(row);
 }
 
@@ -690,7 +692,7 @@ void MathHullInset::mathmlize(MathMLStream & os) const
 }
 
 
-void MathHullInset::infoize(std::ostream & os) const
+void MathHullInset::infoize(ostream & os) const
 {
        os << "Type: " << type_;
 }
@@ -782,95 +784,98 @@ void MathHullInset::doExtern(LCursor & cur, FuncRequest const & func)
 }
 
 
-DispatchResult
-MathHullInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
+void MathHullInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
 {
+       //lyxerr << "*** MathHullInset: request: " << cmd << endl;
        switch (cmd.action) {
 
-               case LFUN_BREAKLINE:
-                       if (type_ == "simple" || type_ == "equation") {
-                               mutate("eqnarray");
-                               cur.idx() = 1;
-                               cur.pos() = 0;
-                               return DispatchResult(true, FINISHED);
-                       }
-                       return MathGridInset::priv_dispatch(cur, cmd);
-
-               case LFUN_MATH_NUMBER:
-                       //lyxerr << "toggling all numbers" << endl;
-                       if (display()) {
-                               //recordUndo(cur, Undo::INSERT);
-                               bool old = numberedType();
-                               if (type_ == "multline")
-                                       numbered(nrows() - 1, !old);
-                               else
-                                       for (row_type row = 0; row < nrows(); ++row)
-                                               numbered(row, !old);
-                               //cur.bv()->owner()->message(old ? _("No number") : _("Number"));
-                       }
-                       return DispatchResult(true, true);
-
-               case LFUN_MATH_NONUMBER:
-                       if (display()) {
-                               row_type r = (type_ == "multline") ? nrows() - 1 : cur.row();
-                               //recordUndo(cur, Undo::INSERT);
-                               bool old = numbered(r);
-                               //cur.bv()->owner()->message(old ? _("No number") : _("Number"));
-                               numbered(r, !old);
-                       }
-                       return DispatchResult(true, true);
-
-               case LFUN_INSERT_LABEL: {
-                       row_type r = (type_ == "multline") ? nrows() - 1 : cur.row();
-                       string old_label = label(r);
-                       string new_label = cmd.argument;
-
-                       if (new_label.empty()) {
-                               string const default_label =
-                                       (lyxrc.label_init_length >= 0) ? "eq:" : "";
-                               pair<bool, string> const res = old_label.empty()
-                                       ? Alert::askForText(_("Enter new label to insert:"), default_label)
-                                       : Alert::askForText(_("Enter label:"), old_label);
-                               if (!res.first)
-                                       return DispatchResult(false);
-                               new_label = trim(res.second);
-                       }
+       case LFUN_BREAKLINE:
+               if (type_ == "simple" || type_ == "equation") {
+                       mutate("eqnarray");
+                       cur.idx() = 1;
+                       cur.pos() = 0;
+                       //cur.dispatched(FINISHED);
+                       return;
+               }
+               MathGridInset::priv_dispatch(cur, cmd);
+               return;
 
-                       //if (new_label == old_label)
-                       //      break;  // Nothing to do
+       case LFUN_MATH_NUMBER:
+               //lyxerr << "toggling all numbers" << endl;
+               if (display()) {
+                       ////recordUndo(cur, Undo::INSERT);
+                       bool old = numberedType();
+                       if (type_ == "multline")
+                               numbered(nrows() - 1, !old);
+                       else
+                               for (row_type row = 0; row < nrows(); ++row)
+                                       numbered(row, !old);
+                       cur.message(old ? _("No number") : _("Number"));
+               }
+               return;
 
-                       if (!new_label.empty())
-                               numbered(r, true);
-                       label(r, new_label);
-                       return DispatchResult(true, true);
+       case LFUN_MATH_NONUMBER:
+               if (display()) {
+                       row_type r = (type_ == "multline") ? nrows() - 1 : cur.row();
+                       ////recordUndo(cur, Undo::INSERT);
+                       bool old = numbered(r);
+                       cur.message(old ? _("No number") : _("Number"));
+                       numbered(r, !old);
                }
+               return;
 
-               case LFUN_MATH_EXTERN:
-                       doExtern(cur, cmd);
-                       return DispatchResult(true, FINISHED);
-
-               case LFUN_MATH_MUTATE: {
-                       lyxerr << "Hull: MUTATE: " << cmd.argument << endl;
-                       row_type r = cur.row();
-                       col_type c = cur.col();
-                       mutate(cmd.argument);
-                       cur.idx() = r * ncols() + c;
-                       if (cur.idx() >= nargs())
-                               cur.idx() = nargs() - 1;
-                       if (cur.pos() > cur.lastpos())
-                               cur.pos() = cur.lastpos();
-                       return DispatchResult(true, FINISHED);
+       case LFUN_INSERT_LABEL: {
+               row_type r = (type_ == "multline") ? nrows() - 1 : cur.row();
+               string old_label = label(r);
+               string new_label = cmd.argument;
+
+               if (new_label.empty()) {
+                       string const default_label =
+                               (lyxrc.label_init_length >= 0) ? "eq:" : "";
+                       pair<bool, string> const res = old_label.empty()
+                               ? Alert::askForText(_("Enter new label to insert:"), default_label)
+                               : Alert::askForText(_("Enter label:"), old_label);
+                       new_label = lyx::support::trim(res.second);
                }
 
-               case LFUN_MATH_DISPLAY: {
-                       mutate(type_ == "simple" ? "equation" : "simple");
-                       cur.idx() = 0;
+               if (!new_label.empty())
+                       numbered(r, true);
+               label(r, new_label);
+               return;
+       }
+
+       case LFUN_MATH_EXTERN:
+               doExtern(cur, cmd);
+               //cur.dispatched(FINISHED);
+               return;
+
+       case LFUN_MATH_MUTATE: {
+               lyxerr << "Hull: MUTATE: " << cmd.argument << endl;
+               row_type row = cur.row();
+               col_type col = cur.col();
+               mutate(cmd.argument);
+               cur.idx() = row * ncols() + col;
+               if (cur.idx() > cur.lastidx()) {
+                       cur.idx() = cur.lastidx();
                        cur.pos() = cur.lastpos();
-                       return DispatchResult(true, FINISHED);
                }
+               if (cur.pos() > cur.lastpos())
+                       cur.pos() = cur.lastpos();
+               //cur.dispatched(FINISHED);
+               return;
+       }
 
-               default:
-                       return MathGridInset::priv_dispatch(cur, cmd);
+       case LFUN_MATH_DISPLAY: {
+               mutate(type_ == "simple" ? "equation" : "simple");
+               cur.idx() = 0;
+               cur.pos() = cur.lastpos();
+               //cur.dispatched(FINISHED);
+               return;
+       }
+
+       default:
+               MathGridInset::priv_dispatch(cur, cmd);
+               return;
        }
 }
 
@@ -885,23 +890,13 @@ string MathHullInset::fileInsetLabel() const
 
 #include "formulamacro.h"
 #include "math_arrayinset.h"
-#include "math_data.h"
 #include "math_deliminset.h"
 #include "math_factory.h"
-#include "math_hullinset.h"
 #include "math_parser.h"
 #include "math_spaceinset.h"
-#include "math_support.h"
 #include "ref_inset.h"
 
-#include "BufferView.h"
 #include "bufferview_funcs.h"
-#include "cursor.h"
-#include "dispatchresult.h"
-#include "debug.h"
-#include "funcrequest.h"
-#include "gettext.h"
-#include "LColor.h"
 #include "lyxtext.h"
 #include "undo.h"
 
@@ -912,37 +907,6 @@ string MathHullInset::fileInsetLabel() const
 #include "support/lstrings.h"
 #include "support/lyxlib.h"
 
-using lyx::support::atoi;
-using lyx::support::split;
-using lyx::support::token;
-
-using std::abs;
-using std::endl;
-using std::max;
-using std::istringstream;
-using std::ostringstream;
-
-
-namespace {
-
-// local global
-int first_x;
-int first_y;
-
-bool openNewInset(LCursor & cur, InsetBase * inset)
-{
-       if (!cur.bv().insertInset(inset)) {
-               delete inset;
-               return false;
-       }
-       inset->edit(cur, true);
-       return true;
-}
-
-
-} // namespace anon
-
-
 
 int MathHullInset::ylow() const
 {
@@ -995,7 +959,7 @@ void MathHullInset::handleFont
 {
        // this whole function is a hack and won't work for incremental font
        // changes...
-       recordUndo(cur, Undo::ATOMIC);
+       //recordUndo(cur, Undo::ATOMIC);
 
        if (cur.inset()->asMathInset()->name() == font)
                cur.handleFont(font);
@@ -1008,7 +972,7 @@ void MathHullInset::handleFont
 
 void MathHullInset::handleFont2(LCursor & cur, string const & arg)
 {
-       recordUndo(cur, Undo::ATOMIC);
+       //recordUndo(cur, Undo::ATOMIC);
        LyXFont font;
        bool b;
        bv_funcs::string2font(arg, font, b);
@@ -1031,7 +995,6 @@ void MathHullInset::insetUnlock(BufferView & bv)
        if (bv.cursor().inMathed()) {
                if (bv.cursor().inMacroMode())
                        bv.cursor().macroModeClose();
-               bv.cursor().releaseMathCursor();
        }
        if (bv.buffer())
                generatePreview(*bv.buffer());
@@ -1039,22 +1002,6 @@ void MathHullInset::insetUnlock(BufferView & bv)
 }
 
 
-void MathHullInset::getCursorPos(BufferView & bv, int & x, int & y) const
-{
-       if (bv.cursor().inMathed()) {
-               bv.cursor().getScreenPos(x, y);
-               x = bv.cursor().targetX();
-               x -= xo_;
-               y -= yo_;
-               lyxerr << "MathHullInset::getCursorPos: " << x << ' ' << y << endl;
-       } else {
-               x = 0;
-               y = 0;
-               lyxerr << "getCursorPos - should not happen";
-       }
-}
-
-
 void MathHullInset::getCursorDim(int & asc, int & desc) const
 {
        asc = 10;
@@ -1063,144 +1010,13 @@ void MathHullInset::getCursorDim(int & asc, int & desc) const
 }
 
 
-DispatchResult
-MathHullInset::lfunMouseRelease(LCursor & cur, FuncRequest const & cmd)
-{
-       if (!cur.inMathed())
-               return DispatchResult(false);
-       cur.bv().update();
-       //lyxerr << "lfunMouseRelease: buttons: " << cmd.button() << endl;
-
-       if (cmd.button() == mouse_button::button3) {
-               // try to dispatch to enclosed insets first
-               if (!cur.dispatch(cmd).dispatched()) {
-                       // launch math panel for right mouse button
-                       lyxerr << "lfunMouseRelease: undispatched: " << cmd.button() << endl;
-                       cur.bv().owner()->getDialogs().show("mathpanel");
-               }
-               return DispatchResult(true, true);
-       }
-
-       if (cmd.button() == mouse_button::button2) {
-               MathArray ar;
-               asArray(cur.bv().getClipboard(), ar);
-               cur.selClear();
-               cur.setScreenPos(cmd.x + xo_, cmd.y + yo_);
-               cur.insert(ar);
-               cur.bv().update();
-               return DispatchResult(true, true);
-       }
-
-       if (cmd.button() == mouse_button::button1) {
-               // try to dispatch to enclosed insets first
-               cur.dispatch(cmd);
-               cur.bv().stuffClipboard(cur.grabSelection());
-               // try to set the cursor
-               //delete mathcursor;
-               //mathcursor = new MathCursor(bv, this, x == 0);
-               //metrics(bv);
-               //cur.setScreenPos(x + xo_, y + yo_);
-               return DispatchResult(true, true);
-       }
-
-       return DispatchResult(false);
-}
-
-
-DispatchResult
-MathHullInset::lfunMousePress(LCursor & cur, FuncRequest const & cmd)
-{
-       //lyxerr << "lfunMousePress: buttons: " << cmd.button() << endl;
-
-       if (!cur.inMathed() || cur.formula() != this) {
-               lyxerr[Debug::MATHED] << "re-create cursor" << endl;
-               cur.releaseMathCursor();
-               cur.idx() = 0;
-               //metrics(bv);
-               cur.setScreenPos(cmd.x + xo_, cmd.y + yo_);
-       }
-
-       if (cmd.button() == mouse_button::button3) {
-               cur.dispatch(cmd);
-               return DispatchResult(true, true);
-       }
-
-       if (cmd.button() == mouse_button::button1) {
-               first_x = cmd.x;
-               first_y = cmd.y;
-               cur.selClear();
-               cur.setScreenPos(cmd.x + xo_, cmd.y + yo_);
-               cur.dispatch(cmd);
-               return DispatchResult(true, true);
-       }
-
-       cur.bv().update();
-       return DispatchResult(true, true);
-}
-
-
-DispatchResult
-MathHullInset::lfunMouseMotion(LCursor & cur, FuncRequest const & cmd)
-{
-       if (!cur.inMathed())
-               return DispatchResult(true, true);
-
-       if (cur.dispatch(FuncRequest(cmd)).dispatched())
-               return DispatchResult(true, true);
-
-       // only select with button 1
-       if (cmd.button() != mouse_button::button1)
-               return DispatchResult(true, true);
-
-       if (abs(cmd.x - first_x) < 2 && abs(cmd.y - first_y) < 2)
-               return DispatchResult(true, true);
-
-       first_x = cmd.x;
-       first_y = cmd.y;
-
-       if (!cur.selection())
-               cur.selBegin();
-
-       cur.setScreenPos(cmd.x + xo_, cmd.y + yo_);
-       cur.bv().update();
-       return DispatchResult(true, true);
-}
-
-
-void MathHullInset::edit(LCursor & cur, bool left)
-{
-       lyxerr << "Called FormulaBase::edit" << endl;
-       cur.push(this);
-       cur.idx() = left ? 0 : cur.lastidx();
-       cur.pos() = left ? 0 : cur.lastpos();
-       cur.resetAnchor();
-}
-
-
-void MathHullInset::edit(LCursor & cur, int x, int y)
-{
-       lyxerr << "Called FormulaBase::EDIT with '" << x << ' ' << y << "'" << endl;
-       //metrics(bv);
-       cur.push(this);
-       //cur.idx() = left ? 0 : cur.lastidx();
-       cur.idx() = 0;
-       cur.idx() = 0;
-       cur.setScreenPos(x + xo_, y + yo_);
-       // if that is removed, we won't get the magenta box when entering an
-       // inset for the first time
-       cur.bv().update();
-}
-
-
-
-
 void MathHullInset::revealCodes(LCursor & cur) const
 {
        if (!cur.inMathed())
                return;
        ostringstream os;
        cur.info(os);
-       cur.bv().owner()->message(os.str());
+       cur.message(os.str());
 /*
        // write something to the minibuffer
        // translate to latex
@@ -1225,7 +1041,7 @@ void MathHullInset::revealCodes(LCursor & cur) const
                res = res.substr(pos - 30);
        if (res.size() > 60)
                res = res.substr(0, 60);
-       bv.owner()->message(res);
+       cur.message(res);
 */
 }
 
@@ -1254,7 +1070,7 @@ bool MathHullInset::searchForward(BufferView * bv, string const & str,
 #warning pretty ugly
 #endif
        static MathHullInset * lastformula = 0;
-       static CursorBase current = CursorBase(ibegin(par().nucleus()));
+       static CursorBase current = DocumentIterator(ibegin(nucleus()));
        static MathArray ar;
        static string laststr;
 
@@ -1262,7 +1078,7 @@ bool MathHullInset::searchForward(BufferView * bv, string const & str,
                //lyxerr << "reset lastformula to " << this << endl;
                lastformula = this;
                laststr = str;
-               current = ibegin(par().nucleus());
+               current = ibegin(nucleus());
                ar.clear();
                mathed_parse_cell(ar, str);
        } else {
@@ -1270,7 +1086,7 @@ bool MathHullInset::searchForward(BufferView * bv, string const & str,
        }
        //lyxerr << "searching '" << str << "' in " << this << ar << endl;
 
-       for (CursorBase it = current; it != iend(par().nucleus()); increment(it)) {
+       for (DocumentIterator it = current; it != iend(nucleus()); increment(it)) {
                CursorSlice & top = it.back();
                MathArray const & a = top.asMathInset()->cell(top.idx_);
                if (a.matchpart(ar, top.pos_)) {
@@ -1292,96 +1108,78 @@ bool MathHullInset::searchForward(BufferView * bv, string const & str,
 bool MathHullInset::searchBackward(BufferView * bv, string const & what,
                                      bool a, bool b)
 {
-       lyxerr[Debug::MATHED] << "searching backward not implemented in mathed" << endl;
+       lyxerr[Debug::MATHED]
+               << "searching backward not implemented in mathed" << endl;
        return searchForward(bv, what, a, b);
 }
 
 
-void mathDispatchCreation(LCursor & cur, FuncRequest const & cmd,
-       bool display)
+void MathHullInset::write(Buffer const &, std::ostream & os) const
 {
-       // use selection if available..
-       //string sel;
-       //if (action == LFUN_MATH_IMPORT_SELECTION)
-       //      sel = "";
-       //else
+       WriteStream wi(os, false, false);
+       os << fileInsetLabel() << ' ';
+       write(wi);
+}
 
-       string sel =
-               cur.bv().getLyXText()->selectionAsString(*cur.bv().buffer(), false);
 
-       if (sel.empty()) {
-               InsetBase * f = new MathHullInset;
-               if (openNewInset(cur, f)) {
-                       cur.inset()->dispatch(cur, FuncRequest(LFUN_MATH_MUTATE, "simple"));
-                       // don't do that also for LFUN_MATH_MODE unless you want end up with
-                       // always changing to mathrm when opening an inlined inset
-                       // -- I really hate "LyXfunc overloading"...
-                       if (display)
-                               f->dispatch(cur, FuncRequest(LFUN_MATH_DISPLAY));
-                       f->dispatch(cur, FuncRequest(LFUN_INSERT_MATH, cmd.argument));
-               }
-       } else {
-               // create a macro if we see "\\newcommand" somewhere, and an ordinary
-               // formula otherwise
-               InsetBase * f;
-               if (sel.find("\\newcommand") == string::npos &&
-                               sel.find("\\def") == string::npos)
-                       f = new MathHullInset(sel);
-               else
-                       f = new InsetFormulaMacro(sel);
-               cur.bv().getLyXText()->cutSelection(true, false);
-               openNewInset(cur, f);
-       }
-       cmd.message(N_("Math editor mode"));
+void MathHullInset::read(Buffer const &, LyXLex & lex)
+{
+       MathAtom at;
+       mathed_parse_normal(at, lex);
+       operator=(*at->asHullInset());
 }
 
 
-void mathDispatch(LCursor & cur, FuncRequest const & cmd)
+int MathHullInset::latex(Buffer const &, ostream & os,
+                       OutputParams const & runparams) const
 {
-       if (!cur.bv().available())
-               return;
+       WriteStream wi(os, runparams.moving_arg, true);
+       write(wi);
+       return wi.line();
+}
 
-       switch (cmd.action) {
 
-               case LFUN_MATH_DISPLAY:
-                       mathDispatchCreation(cur, cmd, true);
-                       break;
+int MathHullInset::plaintext(Buffer const &, ostream & os,
+                       OutputParams const &) const
+{
+       if (0 && display()) {
+               Dimension dim;
+               TextMetricsInfo mi;
+               metricsT(mi, dim);
+               TextPainter tpain(dim.width(), dim.height());
+               drawT(tpain, 0, dim.ascent());
+               tpain.show(os, 3);
+               // reset metrics cache to "real" values
+               //metrics();
+               return tpain.textheight();
+       } else {
+               WriteStream wi(os, false, true);
+               wi << ' ' << cell(0) << ' ';
+               return wi.line();
+       }
+}
 
-               case LFUN_MATH_MODE:
-                       mathDispatchCreation(cur, cmd, false);
-                       break;
 
-               case LFUN_MATH_IMPORT_SELECTION:
-                       mathDispatchCreation(cur, cmd, false);
-                       break;
+int MathHullInset::linuxdoc(Buffer const & buf, ostream & os,
+                          OutputParams const & runparams) const
+{
+       return docbook(buf, os, runparams);
+}
 
-/*
-               case LFUN_MATH_MACRO:
-                       if (cmd.argument.empty())
-                               cmd.errorMessage(N_("Missing argument"));
-                       else {
-                               string s = cmd.argument;
-                               string const s1 = token(s, ' ', 1);
-                               int const nargs = s1.empty() ? 0 : atoi(s1);
-                               string const s2 = token(s, ' ', 2);
-                               string const type = s2.empty() ? "newcommand" : s2;
-                               openNewInset(cur, new InsetFormulaMacro(token(s, ' ', 0), nargs, s2));
-                       }
-                       break;
-
-               case LFUN_INSERT_MATH:
-               case LFUN_INSERT_MATRIX:
-               case LFUN_MATH_DELIM: {
-                       MathHullInset * f = new MathHullInset;
-                       if (openNewInset(cur, f)) {
-                               cur.inset()->dispatch(cur, FuncRequest(LFUN_MATH_MUTATE, "simple"));
-                               cur.inset()->dispatch(cur, cmd);
-                       }
-                       break;
-               }
-*/
 
-               default:
-                       break;
-       }
+int MathHullInset::docbook(Buffer const & buf, ostream & os,
+                         OutputParams const & runparams) const
+{
+       MathMLStream ms(os);
+       ms << MTag("equation");
+       ms <<   MTag("alt");
+       ms <<    "<[CDATA[";
+       int res = plaintext(buf, ms.os(), runparams);
+       ms <<    "]]>";
+       ms <<   ETag("alt");
+       ms <<   MTag("math");
+       MathGridInset::mathmlize(ms);
+       ms <<   ETag("math");
+       ms << ETag("equation");
+       return ms.line() + res;
 }