From 68c43a2b1834e02c47d33a82061021c3bad6a43f Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Tue, 11 Jan 2011 23:55:20 +0000 Subject: [PATCH] XHTML output was a mess for grids output as LaTeX. This will probably still be a mess in many cases, but hopefully we won't have to go here very often. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37181 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/InsetMathHull.cpp | 43 ++++++++++++++++++++++++++++++++++-- src/mathed/InsetMathHull.h | 2 ++ 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp index 5a809e066f..2cb8ea30b1 100644 --- a/src/mathed/InsetMathHull.cpp +++ b/src/mathed/InsetMathHull.cpp @@ -1998,6 +1998,44 @@ void InsetMathHull::mathmlize(MathStream & os) const } +void InsetMathHull::mathAsLatex(WriteStream & os) const +{ + MathEnsurer ensurer(os, false); + 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 << cell(index(0, 0)); + return; + } + + os << ""; + for (row_type row = 0; row < nrows(); ++row) { + os << ""; + for (col_type col = 0; col < ncols(); ++col) { + os << ""; + } + if (havenumbers) { + os << ""; + } + os << ""; + } + os << "
"; + os << cell(index(row, col)); + os << ""; + docstring const & num = numbers_[row]; + if (!num.empty()) + os << '(' << num << ')'; + os << "
"; +} + + docstring InsetMathHull::xhtml(XHTMLStream & xs, OutputParams const & op) const { BufferParams::MathOutput const mathtype = @@ -2075,14 +2113,15 @@ docstring InsetMathHull::xhtml(XHTMLStream & xs, OutputParams const & op) const odocstringstream ls; WriteStream wi(ls, false, true, WriteStream::wsPreview); ModeSpecifier specifier(wi, MATH_MODE); - InsetMathGrid::write(wi); + mathAsLatex(wi); docstring const latex = ls.str(); // class='math' allows for use of jsMath // http://www.math.union.edu/~dpvc/jsMath/ // FIXME XHTML // probably should allow for some kind of customization here - xs << html::StartTag(tag, "class='math'") + xs << html::StartTag(tag, "class='math'") + << XHTMLStream::ESCAPE_AND << latex << html::EndTag(tag); xs.cr(); diff --git a/src/mathed/InsetMathHull.h b/src/mathed/InsetMathHull.h index 53062d3298..fada203531 100644 --- a/src/mathed/InsetMathHull.h +++ b/src/mathed/InsetMathHull.h @@ -132,6 +132,8 @@ public: void mathmlize(MathStream &) const; /// void htmlize(HtmlStream &) const; + /// + void mathAsLatex(WriteStream &) const; /// void toString(odocstream &) const; /// -- 2.39.2