From: Richard Heck Date: Tue, 11 Jan 2011 23:18:56 +0000 (+0000) Subject: Fix equation number output for XHTML+MathML. HTML to come. X-Git-Tag: 2.0.0~1132 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=7ef3d12a800bc05dca8000280637141459d4418f;p=features.git Fix equation number output for XHTML+MathML. HTML to come. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37179 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp index 062935197d..8129508774 100644 --- a/src/mathed/InsetMathHull.cpp +++ b/src/mathed/InsetMathHull.cpp @@ -243,7 +243,8 @@ void InsetMathHull::updateBuffer(ParIterator const & it, UpdateType utype) if (numbered(i) && cnts.hasCounter(eqstr)) { cnts.step(eqstr, utype); numbers_[i] = cnts.theCounter(eqstr, lang); - } + } else + numbers_[i] = empty_docstring(); if (label_[i]) label_[i]->updateBuffer(it, utype); } @@ -1182,12 +1183,6 @@ void InsetMathHull::normalize(NormalStream & os) const } -void InsetMathHull::mathmlize(MathStream & os) const -{ - InsetMathGrid::mathmlize(os); -} - - void InsetMathHull::infoize(odocstream & os) const { os << "Type: " << hullName(type_); @@ -1915,6 +1910,51 @@ int InsetMathHull::docbook(odocstream & os, OutputParams const & runparams) cons } +// this duplicates code from InsetMathGrid, but +// we need access here to label and number information, +// and we simply do not have that in InsetMathGrid. +void InsetMathHull::mathmlize(MathStream & os) const +{ + bool havenumbers = false; + for (size_t i = 0; i != numbered_.size(); ++i) { + if (numbered_[i]) { + havenumbers = true; + break; + } + } + bool const havetable = havenumbers || nrows() > 1 || ncols() > 1; + + if (havetable) + os << MTag("mtable"); + char const * const celltag = havetable ? "mtd" : "mrow"; + // FIXME There does not seem to be wide support at the moment + // for mlabeledtr, so we have to use just mtr for now. + // char const * const rowtag = havenumbers ? "mlabeledtr" : "mtr"; + char const * const rowtag = "mtr"; + for (row_type row = 0; row < nrows(); ++row) { + if (havetable) + os << MTag(rowtag); + for (col_type col = 0; col < ncols(); ++col) { + os << MTag(celltag) + << cell(index(row, col)) + << ETag(celltag); + } + // fleqn? + if (havenumbers) { + os << MTag("mtd"); + docstring const & num = numbers_[row]; + if (!num.empty()) + os << '(' << num << ')'; + os << ETag("mtd"); + } + if (havetable) + os << ETag(rowtag); + } + if (havetable) + os << ETag("mtable"); +} + + docstring InsetMathHull::xhtml(XHTMLStream & xs, OutputParams const & op) const { BufferParams::MathOutput const mathtype = @@ -1926,7 +1966,7 @@ docstring InsetMathHull::xhtml(XHTMLStream & xs, OutputParams const & op) const odocstringstream os; MathStream ms(os); try { - InsetMathGrid::mathmlize(ms); + mathmlize(ms); success = true; } catch (MathExportException const &) {} if (success) { diff --git a/src/mathed/InsetMathHull.h b/src/mathed/InsetMathHull.h index 2fd936916a..6635d8be99 100644 --- a/src/mathed/InsetMathHull.h +++ b/src/mathed/InsetMathHull.h @@ -108,8 +108,6 @@ public: /// void write(WriteStream & os) const; /// - void mathmlize(MathStream &) const; - /// void normalize(NormalStream &) const; /// void infoize(odocstream & os) const; @@ -130,6 +128,8 @@ public: int docbook(odocstream &, OutputParams const &) const; /// docstring xhtml(XHTMLStream &, OutputParams const &) const; + /// + void mathmlize(MathStream &) const; /// void toString(odocstream &) const; ///