X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2FMathExtern.cpp;h=8d1df06f777ee1e78b3bfa8df57c035d5c939e6f;hb=ef7a142f3f4e5937dabf7fb8fc7957bf351e166d;hp=afeba3ebe2519ba1fb89ca57a4464ed2f0e698ce;hpb=3915c2d01a534da1e275dc159c49971cbb170a68;p=lyx.git diff --git a/src/mathed/MathExtern.cpp b/src/mathed/MathExtern.cpp index afeba3ebe2..8d1df06f77 100644 --- a/src/mathed/MathExtern.cpp +++ b/src/mathed/MathExtern.cpp @@ -54,6 +54,7 @@ namespace lyx { namespace { enum ExternalMath { + HTML, MAPLE, MAXIMA, MATHEMATICA, @@ -120,7 +121,7 @@ MathData::iterator extractArgument(MathData & ar, // leave out delimiters if this is a function argument // unless we are doing MathML, in which case we do want // the delimiters - if (function && kind != MATHML) { + 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(); @@ -948,21 +949,22 @@ void extractLims(MathData & ar) void extractStructure(MathData & ar, ExternalMath kind) { //lyxerr << "\nStructure from: " << ar << endl; - if (kind != MATHML) + if (kind != MATHML && kind != HTML) splitScripts(ar); extractDelims(ar); extractIntegrals(ar, kind); - if (kind != MATHML) + 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; } @@ -1417,22 +1419,34 @@ void mathmlize(MathData const & dat, MathStream & os) { MathData ar = dat; extractStructure(ar, MATHML); - if (ar.size() == 0) { - if (!os.inText()) - os << ""; - } else if (ar.size() == 1) + if (ar.size() == 0) + os << ""; + else if (ar.size() == 1) os << ar.front(); else { - if (!os.inText()) - os << MTag("mrow"); + os << MTag("mrow"); for (MathData::const_iterator it = ar.begin(); it != ar.end(); ++it) (*it)->mathmlize(os); - if (!os.inText()) - os << ETag("mrow"); + os << ETag("mrow"); } } +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) { @@ -1482,7 +1496,7 @@ MathData pipeThroughExtern(string const & lang, docstring const & extra, } // 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;