#include "MathExtern.h"
+#include "InsetMathAMSArray.h"
#include "InsetMathArray.h"
#include "InsetMathChar.h"
#include "InsetMathDelim.h"
namespace {
enum ExternalMath {
+ HTML,
MAPLE,
MAXIMA,
MATHEMATICA,
// something delimited _is_ an argument
if ((*pos)->asDelimInset()) {
// leave out delimiters if this is a function argument
- if (function && kind != MATHML) {
+ // unless we are doing MathML, in which case we do want
+ // the delimiters
+ if (function && kind != MATHML && kind != HTML) {
MathData const & arg = (*pos)->asDelimInset()->cell(0);
MathData::const_iterator cur = arg.begin();
MathData::const_iterator end = arg.end();
//lyxerr << "\nMatrices from: " << ar << endl;
// first pass for explicitly delimited stuff
for (size_t i = 0; i < ar.size(); ++i) {
- if (!ar[i]->asDelimInset())
+ InsetMathDelim const * const inset = ar[i]->asDelimInset();
+ if (!inset)
continue;
- MathData const & arr = ar[i]->asDelimInset()->cell(0);
+ MathData const & arr = inset->cell(0);
if (arr.size() != 1)
continue;
if (!arr.front()->asGridInset())
continue;
- ar[i] = MathAtom(new InsetMathMatrix(*(arr.front()->asGridInset())));
+ ar[i] = MathAtom(new InsetMathMatrix(*(arr.front()->asGridInset()),
+ inset->left_, inset->right_));
}
// second pass for AMS "pmatrix" etc
- for (size_t i = 0; i < ar.size(); ++i)
- if (ar[i]->asAMSArrayInset())
- ar[i] = MathAtom(new InsetMathMatrix(*(ar[i]->asGridInset())));
+ for (size_t i = 0; i < ar.size(); ++i) {
+ InsetMathAMSArray const * const inset = ar[i]->asAMSArrayInset();
+ if (inset) {
+ string left = inset->name_left();
+ if (left == "Vert")
+ left = "[";
+ string right = inset->name_right();
+ if (right == "Vert")
+ right = "]";
+ ar[i] = MathAtom(new InsetMathMatrix(*inset, from_ascii(left), from_ascii(right)));
+ }
+ }
//lyxerr << "\nMatrices to: " << ar << endl;
}
void extractStructure(MathData & ar, ExternalMath kind)
{
//lyxerr << "\nStructure from: " << ar << endl;
- splitScripts(ar);
+ if (kind != MATHML && kind != HTML)
+ splitScripts(ar);
extractDelims(ar);
extractIntegrals(ar, kind);
- extractSums(ar);
+ if (kind != MATHML && kind != HTML)
+ extractSums(ar);
extractNumbers(ar);
extractMatrices(ar);
extractFunctions(ar, kind);
- extractDets(ar);
- extractDiff(ar);
- extractExps(ar);
- extractLims(ar);
- if (kind != MATHML)
+ if (kind != MATHML && kind != HTML) {
+ extractDets(ar);
+ extractDiff(ar);
+ extractExps(ar);
+ extractLims(ar);
extractStrings(ar);
+ }
//lyxerr << "\nStructure to: " << ar << endl;
}
}
}
+
+void htmlize(MathData const & dat, HtmlStream & os)
+{
+ MathData ar = dat;
+ extractStructure(ar, HTML);
+ if (ar.size() == 0)
+ return;
+ if (ar.size() == 1) {
+ os << ar.front();
+ return;
+ }
+ for (MathData::const_iterator it = ar.begin(); it != ar.end(); ++it)
+ (*it)->htmlize(os);
+}
+
+
// convert this inset somehow to a number
bool extractNumber(MathData const & ar, int & i)
{
}
// run external sript
- string out = captureOutput(file.absFilename(), data);
+ string out = captureOutput(file.absFileName(), data);
MathData res;
mathed_parse_cell(res, from_utf8(out));
return res;