]> git.lyx.org Git - features.git/commitdiff
XHTML output was a mess for grids output as LaTeX. This will probably
authorRichard Heck <rgheck@comcast.net>
Tue, 11 Jan 2011 23:55:20 +0000 (23:55 +0000)
committerRichard Heck <rgheck@comcast.net>
Tue, 11 Jan 2011 23:55:20 +0000 (23:55 +0000)
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
src/mathed/InsetMathHull.h

index 5a809e066fdc6f7e7262f8cdaaa044a2c60e487a..2cb8ea30b187525aafcf925c435697826a9d22a0 100644 (file)
@@ -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 << "<table class='mathtable'>";
+       for (row_type row = 0; row < nrows(); ++row) {
+               os << "<tr>";
+               for (col_type col = 0; col < ncols(); ++col) {
+                       os << "<td class='math'>";
+                       os << cell(index(row, col));
+                       os << "</td>";
+               }
+               if (havenumbers) {
+                       os << "<td>";
+                       docstring const & num = numbers_[row];
+                       if (!num.empty())
+                               os << '(' << num << ')';
+                 os << "</td>";
+               }
+               os << "</tr>";
+       }
+       os << "</table>";
+}
+
+
 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();
index 53062d329840f37a6a37f51cf1f38bdca8d83bd3..fada2035310b53497a925f9787449cc5abb60a74 100644 (file)
@@ -132,6 +132,8 @@ public:
        void mathmlize(MathStream &) const;
        ///
        void htmlize(HtmlStream &) const;
+       ///
+       void mathAsLatex(WriteStream &) const;
        /// 
        void toString(odocstream &) const;
        ///