2 * \file math_hullinset.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 #include "math_charinset.h"
14 #include "math_data.h"
15 #include "math_extern.h"
16 #include "math_hullinset.h"
17 #include "math_mathmlstream.h"
18 #include "math_streamstr.h"
19 #include "math_support.h"
21 #include "BufferView.h"
23 #include "dispatchresult.h"
25 #include "funcrequest.h"
27 #include "LaTeXFeatures.h"
31 #include "outputparams.h"
32 #include "textpainter.h"
35 #include "insets/render_preview.h"
37 #include "frontends/Alert.h"
39 #include "graphics/PreviewLoader.h"
41 #include "support/std_sstream.h"
43 #include <boost/bind.hpp>
51 using std::istringstream;
53 using std::ostringstream;
61 int getCols(string const & type)
63 if (type == "eqnarray")
67 if (type == "flalign")
69 if (type == "alignat")
71 if (type == "xalignat")
73 if (type == "xxalignat")
79 // returns position of first relation operator in the array
80 // used for "intelligent splitting"
81 size_t firstRelOp(MathArray const & ar)
83 for (MathArray::const_iterator it = ar.begin(); it != ar.end(); ++it)
85 return it - ar.begin();
90 char const * star(bool numbered)
92 return numbered ? "" : "*";
96 int typecode(string const & s)
98 if (s == "none") return 0;
99 if (s == "simple") return 1;
100 if (s == "equation") return 2;
101 if (s == "eqnarray") return 3;
102 if (s == "align") return 4;
103 if (s == "alignat") return 5;
104 if (s == "xalignat") return 6;
105 if (s == "xxalignat") return 7;
106 if (s == "multline") return 8;
107 if (s == "gather") return 9;
108 if (s == "flalign") return 10;
109 lyxerr << "unknown hull type '" << s << "'" << endl;
113 bool smaller(string const & s, string const & t)
115 return typecode(s) < typecode(t);
119 } // end anon namespace
123 MathHullInset::MathHullInset()
124 : MathGridInset(1, 1), type_("none"), nonum_(1), label_(1),
125 preview_(new RenderPreview(this))
127 //lyxerr << "sizeof MathInset: " << sizeof(MathInset) << endl;
128 //lyxerr << "sizeof MetricsInfo: " << sizeof(MetricsInfo) << endl;
129 //lyxerr << "sizeof MathCharInset: " << sizeof(MathCharInset) << endl;
130 //lyxerr << "sizeof LyXFont: " << sizeof(LyXFont) << endl;
135 MathHullInset::MathHullInset(string const & type)
136 : MathGridInset(getCols(type), 1), type_(type), nonum_(1), label_(1),
137 preview_(new RenderPreview(this))
143 MathHullInset::MathHullInset(MathHullInset const & other)
144 : MathGridInset(other),
145 type_(other.type_), nonum_(other.nonum_), label_(other.label_),
146 preview_(new RenderPreview(this))
150 MathHullInset::~MathHullInset()
154 auto_ptr<InsetBase> MathHullInset::clone() const
156 return auto_ptr<InsetBase>(new MathHullInset(*this));
160 void MathHullInset::operator=(MathHullInset const & other)
164 *static_cast<MathGridInset*>(this) = MathGridInset(other);
166 nonum_ = other.nonum_;
167 label_ = other.label_;
168 preview_.reset(new RenderPreview(*other.preview_, this));
172 MathInset::mode_type MathHullInset::currentMode() const
175 return UNDECIDED_MODE;
176 // definitely math mode ...
181 bool MathHullInset::idxFirst(LCursor & cur) const
189 bool MathHullInset::idxLast(LCursor & cur) const
191 cur.idx() = nargs() - 1;
192 cur.pos() = cur.lastpos();
197 char MathHullInset::defaultColAlign(col_type col)
199 if (type_ == "eqnarray")
201 if (typecode(type_) >= typecode("align"))
202 return "rl"[col & 1];
207 int MathHullInset::defaultColSpace(col_type col)
209 if (type_ == "align" || type_ == "alignat")
211 if (type_ == "xalignat")
212 return (col & 1) ? 20 : 0;
213 if (type_ == "xxalignat" || type_ == "flalign")
214 return (col & 1) ? 40 : 0;
219 char const * MathHullInset::standardFont() const
222 return "lyxnochange";
227 void MathHullInset::metrics(MetricsInfo & mi, Dimension & dim) const
229 bool const use_preview = (!editing(mi.base.bv) &&
230 RenderPreview::activated() &&
231 preview_->previewReady());
234 preview_->metrics(mi, dim);
235 // insert a one pixel gap in front of the formula
243 FontSetChanger dummy1(mi.base, standardFont());
244 StyleChanger dummy2(mi.base, display() ? LM_ST_DISPLAY : LM_ST_TEXT);
246 // let the cells adjust themselves
247 MathGridInset::metrics(mi, dim);
254 if (numberedType()) {
255 FontSetChanger dummy(mi.base, "mathbf");
257 for (row_type row = 0; row < nrows(); ++row)
258 l = max(l, mathed_string_width(mi.base.font, nicelabel(row)));
264 // make it at least as high as the current font
267 math_font_max_dim(mi.base.font, asc, des);
268 dim.asc = max(dim.asc, asc);
269 dim.des = max(dim.des, des);
275 void MathHullInset::draw(PainterInfo & pi, int x, int y) const
277 // The previews are drawn only when we're not editing the inset.
278 bool const use_preview = (!editing(pi.base.bv) &&
279 RenderPreview::activated() &&
280 preview_->previewReady());
283 // one pixel gap in front
284 preview_->draw(pi, x + 1, y);
285 setPosCache(pi, x, y);
289 FontSetChanger dummy1(pi.base, standardFont());
290 StyleChanger dummy2(pi.base, display() ? LM_ST_DISPLAY : LM_ST_TEXT);
291 MathGridInset::draw(pi, x + 1, y);
293 if (numberedType()) {
294 int const xx = x + colinfo_.back().offset_ + colinfo_.back().width_ + 20;
295 for (row_type row = 0; row < nrows(); ++row) {
296 int const yy = y + rowinfo_[row].offset_;
297 FontSetChanger dummy(pi.base, "mathrm");
298 drawStr(pi, pi.base.font, xx, yy, nicelabel(row));
301 setPosCache(pi, x, y);
305 void MathHullInset::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
308 MathGridInset::metricsT(mi, dim);
311 WriteStream wi(os, false, true);
313 dim.wid = os.str().size();
320 void MathHullInset::drawT(TextPainter & pain, int x, int y) const
323 MathGridInset::drawT(pain, x, y);
326 WriteStream wi(os, false, true);
328 pain.draw(x, y, os.str().c_str());
335 string const latex_string(MathHullInset const & inset)
338 WriteStream wi(ls, false, false);
346 void MathHullInset::addPreview(lyx::graphics::PreviewLoader & ploader) const
348 string const snippet = latex_string(*this);
349 preview_->addPreview(snippet, ploader);
353 void MathHullInset::notifyCursorLeaves(LCursor & cur)
355 if (!RenderPreview::activated())
358 Buffer const & buffer = cur.buffer();
359 string const snippet = latex_string(*this);
360 preview_->addPreview(snippet, buffer);
361 preview_->startLoading(buffer);
365 string MathHullInset::label(row_type row) const
367 row_type n = nrows();
368 BOOST_ASSERT(row < n);
373 void MathHullInset::label(row_type row, string const & label)
375 //lyxerr << "setting label '" << label << "' for row " << row << endl;
380 void MathHullInset::numbered(row_type row, bool num)
386 bool MathHullInset::numbered(row_type row) const
392 bool MathHullInset::ams() const
396 type_ == "flalign" ||
397 type_ == "multline" ||
399 type_ == "alignat" ||
400 type_ == "xalignat" ||
401 type_ == "xxalignat";
405 bool MathHullInset::display() const
407 return type_ != "simple" && type_ != "none";
411 void MathHullInset::getLabelList(Buffer const &, vector<string> & labels) const
413 for (row_type row = 0; row < nrows(); ++row)
414 if (!label_[row].empty() && nonum_[row] != 1)
415 labels.push_back(label_[row]);
419 bool MathHullInset::numberedType() const
423 if (type_ == "simple")
425 if (type_ == "xxalignat")
427 for (row_type row = 0; row < nrows(); ++row)
434 void MathHullInset::validate(LaTeXFeatures & features) const
437 features.require("amsmath");
440 // Validation is necessary only if not using AMS math.
441 // To be safe, we will always run mathedvalidate.
442 //if (features.amsstyle)
445 features.require("boldsymbol");
446 //features.binom = true;
448 MathGridInset::validate(features);
452 void MathHullInset::header_write(WriteStream & os) const
454 bool n = numberedType();
459 else if (type_ == "simple") {
465 else if (type_ == "equation") {
467 os << "\\begin{equation" << star(n) << "}\n";
472 else if (type_ == "eqnarray" || type_ == "align" || type_ == "flalign"
473 || type_ == "gather" || type_ == "multline")
474 os << "\\begin{" << type_ << star(n) << "}\n";
476 else if (type_ == "alignat" || type_ == "xalignat")
477 os << "\\begin{" << type_ << star(n) << '}'
478 << '{' << static_cast<unsigned int>((ncols() + 1)/2) << "}\n";
480 else if (type_ == "xxalignat")
481 os << "\\begin{" << type_ << '}'
482 << '{' << static_cast<unsigned int>((ncols() + 1)/2) << "}\n";
485 os << "\\begin{unknown" << star(n) << '}';
489 void MathHullInset::footer_write(WriteStream & os) const
491 bool n = numberedType();
496 else if (type_ == "simple")
499 else if (type_ == "equation")
501 os << "\\end{equation" << star(n) << "}\n";
505 else if (type_ == "eqnarray" || type_ == "align" || type_ == "flalign"
506 || type_ == "alignat" || type_ == "xalignat"
507 || type_ == "gather" || type_ == "multline")
508 os << "\\end{" << type_ << star(n) << "}\n";
510 else if (type_ == "xxalignat")
511 os << "\\end{" << type_ << "}\n";
514 os << "\\end{unknown" << star(n) << '}';
518 bool MathHullInset::colChangeOK() const
521 type_ == "align" || type_ == "flalign" ||type_ == "alignat" ||
522 type_ == "xalignat" || type_ == "xxalignat";
526 void MathHullInset::addRow(row_type row)
528 nonum_.insert(nonum_.begin() + row + 1, !numberedType());
529 label_.insert(label_.begin() + row + 1, string());
530 MathGridInset::addRow(row);
534 void MathHullInset::swapRow(row_type row)
538 if (row + 1 == nrows())
540 swap(nonum_[row], nonum_[row + 1]);
541 swap(label_[row], label_[row + 1]);
542 MathGridInset::swapRow(row);
546 void MathHullInset::delRow(row_type row)
550 MathGridInset::delRow(row);
551 nonum_.erase(nonum_.begin() + row);
552 label_.erase(label_.begin() + row);
556 void MathHullInset::addCol(col_type col)
559 MathGridInset::addCol(col);
561 lyxerr << "Can't change number of columns in '" << type_ << "'" << endl;
565 void MathHullInset::delCol(col_type col)
568 MathGridInset::delCol(col);
570 lyxerr << "Can't change number of columns in '" << type_ << "'" << endl;
574 string MathHullInset::nicelabel(row_type row) const
578 if (label_[row].empty())
579 return string("(#)");
580 return '(' + label_[row] + ')';
584 void MathHullInset::glueall()
587 for (idx_type i = 0; i < nargs(); ++i)
589 *this = MathHullInset("simple");
595 string const & MathHullInset::getType() const
601 void MathHullInset::setType(string const & type)
609 void MathHullInset::mutate(string const & newtype)
611 lyxerr << "mutating from '" << type_ << "' to '" << newtype << "'" << endl;
613 // we try to move along the chain
614 // none <-> simple <-> equation <-> eqnarray
616 if (newtype == "dump") {
620 else if (newtype == type_) {
624 else if (type_ == "none") {
630 else if (type_ == "simple") {
631 if (newtype == "none") {
640 else if (type_ == "equation") {
641 if (smaller(newtype, type_)) {
644 } else if (newtype == "eqnarray") {
645 MathGridInset::addCol(1);
646 MathGridInset::addCol(1);
648 // split it "nicely" on the firest relop
649 pos_type pos = firstRelOp(cell(0));
650 cell(1) = MathArray(cell(0).begin() + pos, cell(0).end());
651 cell(0).erase(pos, cell(0).size());
653 if (cell(1).size()) {
654 cell(2) = MathArray(cell(1).begin() + 1, cell(1).end());
655 cell(1).erase(1, cell(1).size());
659 } else if (newtype == "multline" || newtype == "gather") {
663 MathGridInset::addCol(1);
665 pos_type pos = firstRelOp(cell(0));
667 cell(0).erase(pos, cell(0).size());
668 cell(1).erase(0, pos);
674 else if (type_ == "eqnarray") {
675 if (smaller(newtype, type_)) {
676 // set correct (no)numbering
677 bool allnonum = true;
678 for (row_type row = 0; row < nrows(); ++row)
682 // set first non-empty label
684 for (row_type row = 0; row < nrows(); ++row) {
685 if (!label_[row].empty()) {
692 nonum_[0] = allnonum;
695 } else { // align & Co.
696 for (row_type row = 0; row < nrows(); ++row) {
697 idx_type c = 3 * row + 1;
698 cell(c).append(cell(c + 1));
700 MathGridInset::delCol(2);
706 else if (type_ == "align") {
707 if (smaller(newtype, type_)) {
708 MathGridInset::addCol(1);
716 else if (type_ == "multline") {
717 if (newtype == "gather" || newtype == "align" ||
718 newtype == "xalignat" || newtype == "xxalignat" || newtype == "flalign")
720 else if (newtype == "eqnarray") {
721 MathGridInset::addCol(1);
722 MathGridInset::addCol(1);
725 lyxerr << "mutation from '" << type_
726 << "' to '" << newtype << "' not implemented" << endl;
730 else if (type_ == "gather") {
731 if (newtype == "multline") {
734 lyxerr << "mutation from '" << type_
735 << "' to '" << newtype << "' not implemented" << endl;
740 lyxerr << "mutation from '" << type_
741 << "' to '" << newtype << "' not implemented" << endl;
746 string MathHullInset::eolString(row_type row, bool fragile) const
749 if (numberedType()) {
750 if (!label_[row].empty() && !nonum_[row])
751 res += "\\label{" + label_[row] + '}';
752 if (nonum_[row] && (type_ != "multline"))
753 res += "\\nonumber ";
755 return res + MathGridInset::eolString(row, fragile);
759 void MathHullInset::write(WriteStream & os) const
762 MathGridInset::write(os);
767 void MathHullInset::normalize(NormalStream & os) const
769 os << "[formula " << type_ << ' ';
770 MathGridInset::normalize(os);
775 void MathHullInset::mathmlize(MathMLStream & os) const
777 MathGridInset::mathmlize(os);
781 void MathHullInset::infoize(ostream & os) const
783 os << "Type: " << type_;
787 void MathHullInset::check() const
789 BOOST_ASSERT(nonum_.size() == nrows());
790 BOOST_ASSERT(label_.size() == nrows());
794 void MathHullInset::doExtern(LCursor & cur, FuncRequest & func)
798 istringstream iss(func.argument.c_str());
799 iss >> lang >> extra;
804 #warning temporarily disabled
805 //if (cur.selection()) {
808 // lyxerr << "use selection: " << ar << endl;
809 // insert(pipeThroughExtern(lang, extra, ar));
815 eq.push_back(MathAtom(new MathCharInset('=')));
817 // go to first item in line
818 cur.idx() -= cur.idx() % ncols();
821 if (getType() == "simple") {
822 size_type pos = cur.cell().find_last(eq);
824 if (cur.inMathed() && cur.selection()) {
825 asArray(cur.grabAndEraseSelection(), ar);
826 } else if (pos == cur.cell().size()) {
828 lyxerr << "use whole cell: " << ar << endl;
830 ar = MathArray(cur.cell().begin() + pos + 1, cur.cell().end());
831 lyxerr << "use partial cell form pos: " << pos << endl;
833 cur.cell().append(eq);
834 cur.cell().append(pipeThroughExtern(lang, extra, ar));
835 cur.pos() = cur.lastpos();
839 if (getType() == "equation") {
840 lyxerr << "use equation inset" << endl;
842 MathArray & ar = cur.cell();
843 lyxerr << "use cell: " << ar << endl;
847 cur.cell() = pipeThroughExtern(lang, extra, ar);
848 // move to end of line
849 cur.pos() = cur.lastpos();
854 lyxerr << "use eqnarray" << endl;
855 cur.idx() += 2 - cur.idx() % ncols();
857 MathArray ar = cur.cell();
858 lyxerr << "use cell: " << ar << endl;
860 #warning temporarily disabled
867 cur.cell() = pipeThroughExtern(lang, extra, ar);
868 cur.pos() = cur.lastpos();
873 void MathHullInset::priv_dispatch(LCursor & cur, FuncRequest & cmd)
875 switch (cmd.action) {
877 case LFUN_FINISHED_LEFT:
878 case LFUN_FINISHED_RIGHT:
879 case LFUN_FINISHED_UP:
880 case LFUN_FINISHED_DOWN:
881 MathGridInset::priv_dispatch(cur, cmd);
882 notifyCursorLeaves(cur);
885 case LFUN_BREAKPARAGRAPH:
890 if (type_ == "simple" || type_ == "equation") {
894 //cur.dispatched(FINISHED);
897 MathGridInset::priv_dispatch(cur, cmd);
900 case LFUN_MATH_NUMBER:
901 //lyxerr << "toggling all numbers" << endl;
904 bool old = numberedType();
905 if (type_ == "multline")
906 numbered(nrows() - 1, !old);
908 for (row_type row = 0; row < nrows(); ++row)
910 cur.message(old ? _("No number") : _("Number"));
914 case LFUN_MATH_NONUMBER:
916 row_type r = (type_ == "multline") ? nrows() - 1 : cur.row();
918 bool old = numbered(r);
919 cur.message(old ? _("No number") : _("Number"));
924 case LFUN_INSERT_LABEL: {
925 row_type r = (type_ == "multline") ? nrows() - 1 : cur.row();
926 string old_label = label(r);
927 string new_label = cmd.argument;
929 if (new_label.empty()) {
930 string const default_label =
931 (lyxrc.label_init_length >= 0) ? "eq:" : "";
932 pair<bool, string> const res = old_label.empty()
933 ? Alert::askForText(_("Enter new label to insert:"), default_label)
934 : Alert::askForText(_("Enter label:"), old_label);
935 new_label = lyx::support::trim(res.second);
938 if (!new_label.empty())
944 case LFUN_MATH_EXTERN:
946 //cur.dispatched(FINISHED);
949 case LFUN_MATH_MUTATE: {
950 lyxerr << "Hull: MUTATE: " << cmd.argument << endl;
951 row_type row = cur.row();
952 col_type col = cur.col();
953 mutate(cmd.argument);
954 cur.idx() = row * ncols() + col;
955 if (cur.idx() > cur.lastidx()) {
956 cur.idx() = cur.lastidx();
957 cur.pos() = cur.lastpos();
959 if (cur.pos() > cur.lastpos())
960 cur.pos() = cur.lastpos();
961 //cur.dispatched(FINISHED);
965 case LFUN_MATH_DISPLAY: {
966 mutate(type_ == "simple" ? "equation" : "simple");
968 cur.pos() = cur.lastpos();
969 //cur.dispatched(FINISHED);
974 MathGridInset::priv_dispatch(cur, cmd);
980 bool MathHullInset::getStatus(LCursor & cur, FuncRequest const & cmd,
981 FuncStatus & flag) const
983 switch (cmd.action) {
985 case LFUN_MATH_NUMBER:
986 case LFUN_MATH_NONUMBER:
987 case LFUN_INSERT_LABEL:
988 case LFUN_MATH_EXTERN:
989 case LFUN_MATH_MUTATE:
990 case LFUN_MATH_DISPLAY:
994 return MathGridInset::getStatus(cur, cmd, flag);
999 /////////////////////////////////////////////////////////////////////
1001 #include "math_arrayinset.h"
1002 #include "math_deliminset.h"
1003 #include "math_factory.h"
1004 #include "math_parser.h"
1005 #include "math_spaceinset.h"
1006 #include "ref_inset.h"
1008 #include "bufferview_funcs.h"
1009 #include "lyxtext.h"
1011 #include "frontends/LyXView.h"
1012 #include "frontends/Dialogs.h"
1014 #include "support/lstrings.h"
1015 #include "support/lyxlib.h"
1018 // simply scrap this function if you want
1019 void MathHullInset::mutateToText()
1022 // translate to latex
1024 latex(NULL, os, false, false);
1025 string str = os.str();
1028 LyXText * lt = view_->getLyXText();
1029 string::const_iterator cit = str.begin();
1030 string::const_iterator end = str.end();
1031 for (; cit != end; ++cit)
1032 view_->owner()->getIntl()->getTransManager().TranslateAndInsert(*cit, lt);
1035 //view_->owner()->dispatch(LFUN_ESCAPE);
1040 void MathHullInset::handleFont(LCursor & cur, string const & arg,
1041 string const & font)
1043 // this whole function is a hack and won't work for incremental font
1046 if (cur.inset().asMathInset()->name() == font)
1047 cur.handleFont(font);
1049 cur.handleNest(createMathInset(font));
1055 void MathHullInset::handleFont2(LCursor & cur, string const & arg)
1060 bv_funcs::string2font(arg, font, b);
1061 if (font.color() != LColor::inherit) {
1062 MathAtom at = createMathInset("color");
1063 asArray(lcolor.getGUIName(font.color()), at.nucleus()->cell(0));
1064 cur.handleNest(at, 1);
1069 void MathHullInset::edit(LCursor & cur, bool left)
1072 left ? idxFirst(cur) : idxLast(cur);
1076 string const MathHullInset::editMessage() const
1078 return _("Math editor mode");
1082 void MathHullInset::getCursorDim(int & asc, int & desc) const
1086 //math_font_max_dim(font_, asc, des);
1090 void MathHullInset::revealCodes(LCursor & cur) const
1092 if (!cur.inMathed())
1096 cur.message(os.str());
1098 // write something to the minibuffer
1099 // translate to latex
1103 string str = os.str();
1105 string::size_type pos = 0;
1107 for (string::iterator it = str.begin(); it != str.end(); ++it) {
1110 else if (*it == '\0') {
1112 pos = it - str.begin();
1118 res = res.substr(pos - 30);
1119 if (res.size() > 60)
1120 res = res.substr(0, 60);
1126 InsetBase::Code MathHullInset::lyxCode() const
1132 /////////////////////////////////////////////////////////////////////
1136 bool MathHullInset::searchForward(BufferView * bv, string const & str,
1139 #warning completely broken
1140 static MathHullInset * lastformula = 0;
1141 static CursorBase current = DocIterator(ibegin(nucleus()));
1142 static MathArray ar;
1143 static string laststr;
1145 if (lastformula != this || laststr != str) {
1146 //lyxerr << "reset lastformula to " << this << endl;
1149 current = ibegin(nucleus());
1151 mathed_parse_cell(ar, str);
1155 //lyxerr << "searching '" << str << "' in " << this << ar << endl;
1157 for (DocIterator it = current; it != iend(nucleus()); increment(it)) {
1158 CursorSlice & top = it.back();
1159 MathArray const & a = top.asMathInset()->cell(top.idx_);
1160 if (a.matchpart(ar, top.pos_)) {
1161 bv->cursor().setSelection(it, ar.size());
1163 top.pos_ += ar.size();
1169 //lyxerr << "not found!" << endl;
1176 void MathHullInset::write(Buffer const &, std::ostream & os) const
1178 WriteStream wi(os, false, false);
1184 void MathHullInset::read(Buffer const &, LyXLex & lex)
1187 mathed_parse_normal(at, lex);
1188 operator=(*at->asHullInset());
1192 int MathHullInset::plaintext(Buffer const &, ostream & os,
1193 OutputParams const &) const
1195 if (0 && display()) {
1199 TextPainter tpain(dim.width(), dim.height());
1200 drawT(tpain, 0, dim.ascent());
1202 // reset metrics cache to "real" values
1204 return tpain.textheight();
1206 WriteStream wi(os, false, true);
1207 wi << ' ' << cell(0) << ' ';
1213 int MathHullInset::linuxdoc(Buffer const & buf, ostream & os,
1214 OutputParams const & runparams) const
1216 return docbook(buf, os, runparams);
1220 int MathHullInset::docbook(Buffer const & buf, ostream & os,
1221 OutputParams const & runparams) const
1223 MathMLStream ms(os);
1224 ms << MTag("equation");
1227 int res = plaintext(buf, ms.os(), runparams);
1231 MathGridInset::mathmlize(ms);
1233 ms << ETag("equation");
1234 return ms.line() + res;