Hi,

This week-end I started the mathematica facilities. I've trying compile 
lyx-devel from the CVS repository without success : I get a "Illegal 
instruction" when I try to run lyx. So I worked with the 1.2.0 version of 
lyx!
The implementation is quite completed excepted for the matrix support which is 
missing. I'm planning to improve the derivative support and add limit 
support.
Feedback is welcome.

                geof

-- 
    ~
   'v'    mailto: gpiroux_at_mac_dot_com
  // \\   Powered by GNU/Linux-ppc
 /(   )\  http://lfs.linux-provider.net/  #112
   ^'^
diff -u lyx-1.2.0/src/mathed/formula.C lyx-1.2.0_mma/src/mathed/formula.C
--- lyx-1.2.0/src/mathed/formula.C	Thu May  2 09:30:49 2002
+++ lyx-1.2.0_mma/src/mathed/formula.C	Sun Jun 30 17:39:26 2002
@@ -143,6 +143,65 @@
 	}
 
 
+
+	MathArray pipeThroughMathematica(string const & extra, MathArray const & ar)
+	{
+		ostringstream os;
+		MathematicaStream vs(os);
+		vs << ar;
+		string expr = os.str().c_str();
+		string tex_expr;
+		string out;
+
+		if ( extra != "noextra" ) 
+			tex_expr = "TeXForm[" + extra + '[' + expr + "]]";
+		else
+			tex_expr = "TeXForm[" + expr  + ']';
+
+		lyxerr << "\n==============================================\n";
+		lyxerr << "checking expr:     '" << expr << "'\n";
+		lyxerr << "checking tex_expr: '" << tex_expr << "'\n\n";
+		out = captureOutput("math", tex_expr);
+		
+		lyxerr << "\n";
+		
+		/** Parsing of the result **/
+		// search line with Out[1]
+		istringstream is(out.c_str());
+		string line;
+		while (is) {
+			getline(is, line);
+			lyxerr << "skipping line: '" << line << "'\n";
+			if (line.find("In[1]:=") != string::npos)
+				break;
+		}
+
+		getline(is, line);
+		string::size_type pos = line.find("Out[1]//TeXForm=");
+		lyxerr << "line: '" << line << "'\n";
+		if (pos == string::npos)
+			return ar;   //no result
+		
+		line.replace(pos, pos + 16, ""); // remove "Out[1]//TeXForm="
+		string out_ = line;              // out_ is the parsed out
+		
+		while (is) {
+			getline(is, line);
+			lyxerr << "line: '" << line << "'\n";
+			if ( line.size() != 0 )
+				out_ += line;
+			else
+				break; // breack when line is empty
+		}
+
+		lyxerr << "\n\nout_ : " << out_ << "\n";
+	
+		MathArray res;
+		mathed_parse_cell(res, out_);
+		return res;
+	}
+
+
 	MathArray pipeThroughOctave(string const &, MathArray const & ar)
 	{
 		ostringstream os;
@@ -217,6 +276,10 @@
 
 		if (lang == "maple")
 			return pipeThroughMaple(extra, ar);
+		
+		if (lang == "mma")
+			return pipeThroughMathematica(extra, ar);
+
 
 		// create normalized expression
 		ostringstream os;
Only in lyx-1.2.0_mma/src/mathed: libmathed.la
diff -u lyx-1.2.0/src/mathed/math_deliminset.C lyx-1.2.0_mma/src/mathed/math_deliminset.C
--- lyx-1.2.0/src/mathed/math_deliminset.C	Thu Mar 21 18:42:55 2002
+++ lyx-1.2.0_mma/src/mathed/math_deliminset.C	Wed Jun 26 23:45:34 2002
@@ -110,6 +110,22 @@
 		os << left_ << cell(0) << right_;
 }
 
+void MathDelimInset::mathematicize(MathematicaStream & os) const
+{
+	if (isAbs()) {
+		bool mat =
+			cell(0).size() == 1 && cell(0).begin()->nucleus()
+					&& cell(0).begin()->nucleus()->asMatrixInset();
+		if (mat)
+			os << "Det" << cell(0) << ']';
+		else
+			os << "Abs[" << cell(0) << ']';
+	}
+	else
+		os << left_ << cell(0) << right_;
+}
+
+
 
 void MathDelimInset::mathmlize(MathMLStream & os) const
 {
diff -u lyx-1.2.0/src/mathed/math_deliminset.h lyx-1.2.0_mma/src/mathed/math_deliminset.h
--- lyx-1.2.0/src/mathed/math_deliminset.h	Thu Feb 14 13:38:02 2002
+++ lyx-1.2.0_mma/src/mathed/math_deliminset.h	Wed Jun 26 23:46:06 2002
@@ -41,6 +41,8 @@
 	///
 	void maplize(MapleStream &) const;
 	///
+	void mathematicize(MathematicaStream &) const;
+	///
 	void mathmlize(MathMLStream &) const;
 	///
 	void octavize(OctaveStream &) const;
diff -u lyx-1.2.0/src/mathed/math_diffinset.C lyx-1.2.0_mma/src/mathed/math_diffinset.C
--- lyx-1.2.0/src/mathed/math_diffinset.C	Thu Mar 21 18:42:55 2002
+++ lyx-1.2.0_mma/src/mathed/math_diffinset.C	Sun Jun 30 15:41:23 2002
@@ -55,6 +55,17 @@
 	os << ')';
 }
 
+void MathDiffInset::mathematicize(MathematicaStream & os) const
+{
+	os << "Dt[";
+	for (idx_type idx = 0; idx < nargs(); ++idx) {
+		if (idx != 0)
+			os << ',';
+		os << cell(idx);
+	}
+	os << ']';
+}
+
 
 void MathDiffInset::mathmlize(MathMLStream & os) const
 {
diff -u lyx-1.2.0/src/mathed/math_diffinset.h lyx-1.2.0_mma/src/mathed/math_diffinset.h
--- lyx-1.2.0/src/mathed/math_diffinset.h	Tue Nov 13 17:27:06 2001
+++ lyx-1.2.0_mma/src/mathed/math_diffinset.h	Sun Jun 30 15:39:09 2002
@@ -25,6 +25,8 @@
 	///
 	void maplize(MapleStream &) const;
 	///
+	void mathematicize(MathematicaStream &) const;
+	///
 	void mathmlize(MathMLStream &) const;
 	///
 	void write(WriteStream & os) const;
diff -u lyx-1.2.0/src/mathed/math_exfuncinset.C lyx-1.2.0_mma/src/mathed/math_exfuncinset.C
--- lyx-1.2.0/src/mathed/math_exfuncinset.C	Thu Mar 21 18:42:55 2002
+++ lyx-1.2.0_mma/src/mathed/math_exfuncinset.C	Sun Jun 30 14:41:46 2002
@@ -41,6 +41,27 @@
 	os << name_ << '(' << cell(0) << ')';
 }
 
+void MathExFuncInset::mathematicize(MathematicaStream & os) const
+{
+	if ( name_ == "sin" )    { os << "Sin[" << cell(0) << ']'; return;}
+	if ( name_ == "sinh" )   { os << "Sinh[" << cell(0) << ']'; return;}
+	if ( name_ == "arcsin" ) { os << "ArcSin[" << cell(0) << ']'; return;}
+	if ( name_ == "cos" )    { os << "Cos[" << cell(0) << ']'; return;}
+	if ( name_ == "cosh" )   { os << "Cosh[" << cell(0) << ']'; return;}
+	if ( name_ == "arcos" )  { os << "ArcCos[" << cell(0) << ']'; return;}
+	if ( name_ == "tan" )    { os << "Tan[" << cell(0) << ']'; return;}
+	if ( name_ == "tanh" )   { os << "Tanh[" << cell(0) << ']'; return;}
+	if ( name_ == "arctan" ) { os << "ArcTan[" << cell(0) << ']'; return;}
+	if ( name_ == "cot" )    { os << "Cot[" << cell(0) << ']'; return;}
+	if ( name_ == "coth" )   { os << "Coth[" << cell(0) << ']'; return;}
+	if ( name_ == "csc" )    { os << "Csc[" << cell(0) << ']'; return;}
+	if ( name_ == "sec" )    { os << "Sec[" << cell(0) << ']'; return;}
+	if ( name_ == "exp" )    { os << "Exp[" << cell(0) << ']'; return;}
+	if ( name_ == "log" || name_ == "ln" ) 
+	                         { os << "Log[" << cell(0) << ']'; return;}
+	os << name_ << '[' << cell(0) << ']';
+}
+
 
 void MathExFuncInset::mathmlize(MathMLStream & os) const
 {
diff -u lyx-1.2.0/src/mathed/math_exfuncinset.h lyx-1.2.0_mma/src/mathed/math_exfuncinset.h
--- lyx-1.2.0/src/mathed/math_exfuncinset.h	Tue Mar 19 17:55:58 2002
+++ lyx-1.2.0_mma/src/mathed/math_exfuncinset.h	Thu Jun 27 10:38:09 2002
@@ -23,6 +23,8 @@
 	///
 	void maplize(MapleStream &) const;
 	///
+	void mathematicize(MathematicaStream &) const;
+	///
 	void mathmlize(MathMLStream &) const;
 	///
 	void octavize(OctaveStream &) const;
diff -u lyx-1.2.0/src/mathed/math_exintinset.C lyx-1.2.0_mma/src/mathed/math_exintinset.C
--- lyx-1.2.0/src/mathed/math_exintinset.C	Thu Mar 21 18:42:55 2002
+++ lyx-1.2.0_mma/src/mathed/math_exintinset.C	Sun Jun 30 15:15:38 2002
@@ -74,6 +74,26 @@
 	os << ')';
 }
 
+void MathExIntInset::mathematicize(MathematicaStream & os) const
+{
+	if ( symbol_ == "int" ) 
+		os << "Integrate[";
+	else 
+		if (symbol_ == "sum") 
+			os << "Sum[";
+		else 
+			os << symbol_ << '[';
+	
+	if (cell(0).size())
+		os << cell(0) << ',';
+	else
+		os << '1' << ',';
+	if (hasScripts())
+		os << '{' << cell(1) << ',' << cell(2) << ',' << cell(3) << "}]";
+	else 
+		os << cell(1) << ']';
+}
+
 
 void MathExIntInset::mathmlize(MathMLStream & os) const
 {
diff -u lyx-1.2.0/src/mathed/math_exintinset.h lyx-1.2.0_mma/src/mathed/math_exintinset.h
--- lyx-1.2.0/src/mathed/math_exintinset.h	Thu Nov 15 15:14:37 2001
+++ lyx-1.2.0_mma/src/mathed/math_exintinset.h	Sun Jun 30 15:06:17 2002
@@ -26,6 +26,8 @@
 	///
 	void maplize(MapleStream &) const;
 	///
+	void mathematicize(MathematicaStream &) const;
+	///
 	void mathmlize(MathMLStream &) const;
 	///
 	void write(WriteStream & os) const;
diff -u lyx-1.2.0/src/mathed/math_extern.C lyx-1.2.0_mma/src/mathed/math_extern.C
--- lyx-1.2.0/src/mathed/math_extern.C	Wed Apr 24 19:07:42 2002
+++ lyx-1.2.0_mma/src/mathed/math_extern.C	Wed Jun 26 21:34:08 2002
@@ -797,6 +797,24 @@
 }
 
 
+void mathematicize(MathArray const & dat, MathematicaStream & os)
+{
+	MathArray ar = dat;
+	extractStructure(ar);
+	for (MathArray::const_iterator it = ar.begin(); it != ar.end(); ++it) {
+		MathInset const * p = it->nucleus();
+		if (it + 1 != ar.end()) {
+			if (MathScriptInset const * q = asScript(it)) {
+				q->mathematicize2(p, os);
+				++it;
+				continue;
+			}
+		}
+		p->mathematicize(os);
+	}
+}
+
+
 void mathmlize(MathArray const & dat, MathMLStream & os)
 {
 	MathArray ar = dat;
diff -u lyx-1.2.0/src/mathed/math_extern.h lyx-1.2.0_mma/src/mathed/math_extern.h
--- lyx-1.2.0/src/mathed/math_extern.h	Mon Mar 25 13:11:24 2002
+++ lyx-1.2.0_mma/src/mathed/math_extern.h	Wed Jun 26 21:15:08 2002
@@ -3,6 +3,7 @@
 
 class NormalStream;
 class MapleStream;
+class MathematicaStream;
 class MathMLStream;
 class OctaveStream;
 class WriteStream;
@@ -11,6 +12,7 @@
 void write(MathArray const &, WriteStream &);
 void normalize(MathArray const &, NormalStream &);
 void maplize(MathArray const &, MapleStream &);
+void mathematicize(MathArray const &, MathematicaStream &);
 void mathmlize(MathArray const &, MathMLStream &);
 void octavize(MathArray const &, OctaveStream &);
 
diff -u lyx-1.2.0/src/mathed/math_fracinset.C lyx-1.2.0_mma/src/mathed/math_fracinset.C
--- lyx-1.2.0/src/mathed/math_fracinset.C	Thu Apr 25 17:37:10 2002
+++ lyx-1.2.0_mma/src/mathed/math_fracinset.C	Wed Jun 26 22:45:45 2002
@@ -89,12 +89,15 @@
 	os << cell(0) << ' ' << cell(1) << ']';
 }
 
-
 void MathFracInset::maplize(MapleStream & os) const
 {
 	os << '(' << cell(0) << ")/(" << cell(1) << ')';
 }
 
+void MathFracInset::mathematicize(MathematicaStream & os) const
+{
+	os << '(' << cell(0) << ")/(" << cell(1) << ')';
+}
 
 void MathFracInset::octavize(OctaveStream & os) const
 {
diff -u lyx-1.2.0/src/mathed/math_fracinset.h lyx-1.2.0_mma/src/mathed/math_fracinset.h
--- lyx-1.2.0/src/mathed/math_fracinset.h	Thu Apr 25 17:37:10 2002
+++ lyx-1.2.0_mma/src/mathed/math_fracinset.h	Wed Jun 26 22:47:32 2002
@@ -35,6 +35,8 @@
 	///
 	void maplize(MapleStream &) const;
 	///
+	void mathematicize(MathematicaStream &) const;
+	///
 	void octavize(OctaveStream &) const;
 	///
 	void mathmlize(MathMLStream &) const;
diff -u lyx-1.2.0/src/mathed/math_funcinset.C lyx-1.2.0_mma/src/mathed/math_funcinset.C
--- lyx-1.2.0/src/mathed/math_funcinset.C	Thu Mar 21 18:42:55 2002
+++ lyx-1.2.0_mma/src/mathed/math_funcinset.C	Thu Jun 27 10:28:31 2002
@@ -57,8 +57,12 @@
 	return q && name_ == q->name_;
 }
 
-
 void MathFuncInset::maplize(MapleStream & os) const
+{
+	os << ' ' << name_;
+}
+
+void MathFuncInset::mathematicize(MathematicaStream & os) const
 {
 	os << ' ' << name_;
 }
diff -u lyx-1.2.0/src/mathed/math_funcinset.h lyx-1.2.0_mma/src/mathed/math_funcinset.h
--- lyx-1.2.0/src/mathed/math_funcinset.h	Tue Mar 19 17:55:58 2002
+++ lyx-1.2.0_mma/src/mathed/math_funcinset.h	Thu Jun 27 10:27:24 2002
@@ -36,6 +36,8 @@
 	///
 	void maplize(MapleStream &) const;
 	///
+	void mathematicize(MathematicaStream &) const;
+	///
 	void mathmlize(MathMLStream &) const;
 	///
 	void octavize(OctaveStream &) const;
diff -u lyx-1.2.0/src/mathed/math_inset.C lyx-1.2.0_mma/src/mathed/math_inset.C
--- lyx-1.2.0/src/mathed/math_inset.C	Mon Apr  8 10:12:09 2002
+++ lyx-1.2.0_mma/src/mathed/math_inset.C	Wed Jun 26 21:31:03 2002
@@ -230,6 +230,13 @@
 }
 
 
+void MathInset::mathematicize(MathematicaStream & os) const
+{
+	NormalStream ns(os.os());
+	normalize(ns);
+}
+
+
 void MathInset::mathmlize(MathMLStream & os) const
 {
 	NormalStream ns(os.os());
diff -u lyx-1.2.0/src/mathed/math_inset.h lyx-1.2.0_mma/src/mathed/math_inset.h
--- lyx-1.2.0/src/mathed/math_inset.h	Wed Apr 24 19:07:42 2002
+++ lyx-1.2.0_mma/src/mathed/math_inset.h	Wed Jun 26 21:29:17 2002
@@ -68,6 +68,7 @@
 class NormalStream;
 class OctaveStream;
 class MapleStream;
+class MathematicaStream;
 class MathMLStream;
 class WriteStream;
 class InfoStream;
@@ -243,6 +244,8 @@
 	virtual void normalize(NormalStream &) const;
 	/// write content as something readable by Maple
 	virtual void maplize(MapleStream &) const;
+	/// write content as something readable by Mathematica
+	virtual void mathematicize(MathematicaStream &) const;
 	/// write content as something resembling MathML
 	virtual void mathmlize(MathMLStream &) const;
 	/// write content as something readable by Octave
diff -u lyx-1.2.0/src/mathed/math_mathmlstream.C lyx-1.2.0_mma/src/mathed/math_mathmlstream.C
--- lyx-1.2.0/src/mathed/math_mathmlstream.C	Wed Apr 24 19:07:42 2002
+++ lyx-1.2.0_mma/src/mathed/math_mathmlstream.C	Wed Jun 26 22:03:12 2002
@@ -118,6 +118,48 @@
 //////////////////////////////////////////////////////////////////////
 
 
+MathematicaStream & operator<<(MathematicaStream & ms, MathInset const * p)
+{
+	if (p)
+		p->mathematicize(ms);
+	else
+		lyxerr << "operator<<(MathematicaStream, NULL) called\n";
+	return ms;
+}
+
+
+MathematicaStream & operator<<(MathematicaStream & ms, MathArray const & ar)
+{
+	mathematicize(ar, ms);
+	return ms;
+}
+
+
+MathematicaStream & operator<<(MathematicaStream & ms, char const * s)
+{
+	ms.os() << s;
+	return ms;
+}
+
+
+MathematicaStream & operator<<(MathematicaStream & ms, char c)
+{
+	ms.os() << c;
+	return ms;
+}
+
+
+MathematicaStream & operator<<(MathematicaStream & ms, int i)
+{
+	ms.os() << i;
+	return ms;
+}
+
+
+
+//////////////////////////////////////////////////////////////////////
+
+
 OctaveStream & operator<<(OctaveStream & ns, MathInset const * p)
 {
 	if (p)
diff -u lyx-1.2.0/src/mathed/math_mathmlstream.h lyx-1.2.0_mma/src/mathed/math_mathmlstream.h
--- lyx-1.2.0/src/mathed/math_mathmlstream.h	Wed Apr 24 19:07:42 2002
+++ lyx-1.2.0_mma/src/mathed/math_mathmlstream.h	Wed Jun 26 21:20:11 2002
@@ -127,6 +127,35 @@
 
 
 //
+// Mathematica
+//
+
+
+class MathematicaStream {
+public:
+	///
+	explicit MathematicaStream(std::ostream & os) : os_(os) {}
+	///
+	std::ostream & os() { return os_; }
+private:
+	///
+	std::ostream & os_;
+};
+
+
+///
+MathematicaStream & operator<<(MathematicaStream &, MathInset const *);
+///
+MathematicaStream & operator<<(MathematicaStream &, MathArray const &);
+///
+MathematicaStream & operator<<(MathematicaStream &, char const *);
+///
+MathematicaStream & operator<<(MathematicaStream &, char);
+///
+MathematicaStream & operator<<(MathematicaStream &, int);
+
+
+//
 // Octave
 //
 
diff -u lyx-1.2.0/src/mathed/math_scriptinset.C lyx-1.2.0_mma/src/mathed/math_scriptinset.C
--- lyx-1.2.0/src/mathed/math_scriptinset.C	Thu Apr 25 17:37:10 2002
+++ lyx-1.2.0_mma/src/mathed/math_scriptinset.C	Wed Jun 26 21:49:06 2002
@@ -411,6 +411,25 @@
 }
 
 
+void MathScriptInset::mathematicize2(MathInset const * nuc, MathematicaStream & os) const
+{
+	bool d = hasDown() && down().data_.size();
+	bool u = hasUp() && up().data_.size();
+
+	if (nuc)
+		if (d)  //subscript only if nuc !
+			os << "Subscript[" << nuc;
+		else
+			os << nuc;
+	if (u)
+		os << "^(" << up().data_ << ")";
+
+	if (nuc)
+		if (d)
+		os << "," << down().data_ << "]"; 
+}
+
+
 void MathScriptInset::mathmlize2(MathInset const * nuc, MathMLStream & os) const
 {
 	bool d = hasDown() && down().data_.size();
diff -u lyx-1.2.0/src/mathed/math_scriptinset.h lyx-1.2.0_mma/src/mathed/math_scriptinset.h
--- lyx-1.2.0/src/mathed/math_scriptinset.h	Thu Mar 21 18:42:56 2002
+++ lyx-1.2.0_mma/src/mathed/math_scriptinset.h	Wed Jun 26 21:38:09 2002
@@ -93,6 +93,7 @@
 	virtual void normalize2(MathInset const * nuc, NormalStream & os) const;
 	virtual void octavize2(MathInset const * nuc, OctaveStream & os) const;
 	virtual void maplize2(MathInset const * nuc, MapleStream & os) const;
+	virtual void mathematicize2(MathInset const * nuc, MathematicaStream & os) const;
 	virtual void mathmlize2(MathInset const * nuc, MathMLStream & os) const;
 
 public:
diff -u lyx-1.2.0/src/mathed/math_spaceinset.C lyx-1.2.0_mma/src/mathed/math_spaceinset.C
--- lyx-1.2.0/src/mathed/math_spaceinset.C	Mon Mar 25 13:11:25 2002
+++ lyx-1.2.0_mma/src/mathed/math_spaceinset.C	Wed Jun 26 23:49:08 2002
@@ -74,6 +74,11 @@
 	os << ' ';
 }
 
+void MathSpaceInset::mathematicize(MathematicaStream & os) const
+{
+	os << ' ';
+}
+
 
 void MathSpaceInset::octavize(OctaveStream & os) const
 {
diff -u lyx-1.2.0/src/mathed/math_spaceinset.h lyx-1.2.0_mma/src/mathed/math_spaceinset.h
--- lyx-1.2.0/src/mathed/math_spaceinset.h	Thu Nov 15 15:14:37 2001
+++ lyx-1.2.0_mma/src/mathed/math_spaceinset.h	Wed Jun 26 23:47:45 2002
@@ -32,6 +32,8 @@
 	///
 	void maplize(MapleStream &) const;
 	///
+	void mathematicize(MathematicaStream &) const;
+	///
 	void octavize(OctaveStream &) const;
 	///
 	void write(WriteStream & os) const;
diff -u lyx-1.2.0/src/mathed/math_sqrtinset.C lyx-1.2.0_mma/src/mathed/math_sqrtinset.C
--- lyx-1.2.0/src/mathed/math_sqrtinset.C	Thu Apr 25 07:58:55 2002
+++ lyx-1.2.0_mma/src/mathed/math_sqrtinset.C	Wed Jun 26 22:52:54 2002
@@ -73,10 +73,14 @@
 	os << "[sqrt " << cell(0) << ']';
 }
 
-
 void MathSqrtInset::maplize(MapleStream & os) const
 {
 	os << "sqrt(" << cell(0) << ')';
+}
+
+void MathSqrtInset::mathematicize(MathematicaStream & os) const
+{
+	os << "Sqrt[" << cell(0) << ']';
 }
 
 
diff -u lyx-1.2.0/src/mathed/math_sqrtinset.h lyx-1.2.0_mma/src/mathed/math_sqrtinset.h
--- lyx-1.2.0/src/mathed/math_sqrtinset.h	Thu Apr 25 07:58:55 2002
+++ lyx-1.2.0_mma/src/mathed/math_sqrtinset.h	Wed Jun 26 22:55:49 2002
@@ -33,6 +33,8 @@
 	///
 	void maplize(MapleStream &) const;
 	///
+	void mathematicize(MathematicaStream &) const;
+	///
 	void octavize(OctaveStream &) const;
 	///
 	void mathmlize(MathMLStream &) const;
diff -u lyx-1.2.0/src/mathed/math_streamstr.C lyx-1.2.0_mma/src/mathed/math_streamstr.C
--- lyx-1.2.0/src/mathed/math_streamstr.C	Mon Jan 14 14:04:06 2002
+++ lyx-1.2.0_mma/src/mathed/math_streamstr.C	Wed Jun 26 23:22:35 2002
@@ -28,6 +28,13 @@
 }
 
 
+MathematicaStream & operator<<(MathematicaStream & ms, string const & s)
+{
+	ms.os() << s;
+	return ms;
+}
+
+
 MathMLStream & operator<<(MathMLStream & ms, string const & s)
 {
 	ms.os() << s;
diff -u lyx-1.2.0/src/mathed/math_streamstr.h lyx-1.2.0_mma/src/mathed/math_streamstr.h
--- lyx-1.2.0/src/mathed/math_streamstr.h	Wed Dec  5 09:04:19 2001
+++ lyx-1.2.0_mma/src/mathed/math_streamstr.h	Wed Jun 26 21:17:29 2002
@@ -7,6 +7,7 @@
 class WriteStream;
 class NormalStream;
 class MapleStream;
+class MathematicaStream;
 class MathMLStream;
 class OctaveStream;
 
@@ -17,6 +18,7 @@
 WriteStream & operator<<(WriteStream & ws, string const & s);
 NormalStream & operator<<(NormalStream & ns, string const & s);
 MapleStream & operator<<(MapleStream & ms, string const & s);
+MathematicaStream & operator<<(MathematicaStream & ms, string const & s);
 MathMLStream & operator<<(MathMLStream & ms, string const & s);
 OctaveStream & operator<<(OctaveStream & os, string const & s);
 #endif
diff -u lyx-1.2.0/src/mathed/math_stringinset.C lyx-1.2.0_mma/src/mathed/math_stringinset.C
--- lyx-1.2.0/src/mathed/math_stringinset.C	Thu Mar 21 18:42:56 2002
+++ lyx-1.2.0_mma/src/mathed/math_stringinset.C	Thu Jun 27 10:13:03 2002
@@ -76,7 +76,6 @@
 	os << "[string " << str_ << ' ' << "mathalpha" << "]";
 }
 
-
 void MathStringInset::maplize(MapleStream & os) const
 {
 	if (code_ != LM_TC_VAR || str_.size() <= 1) {
@@ -90,6 +89,18 @@
 		os << '*' << str_[i];
 }
 
+void MathStringInset::mathematicize(MathematicaStream & os) const
+{
+	if (code_ != LM_TC_VAR || str_.size() <= 1) {
+		os << ' ' << str_ << ' ';
+		return;
+	}
+
+	// insert '*' between adjacent chars if type is LM_TC_VAR
+	os << str_[0];
+	for (string::size_type i = 1; i < str_.size(); ++i)
+		os << '*' << str_[i];
+}
 
 void MathStringInset::octavize(OctaveStream & os) const
 {
diff -u lyx-1.2.0/src/mathed/math_stringinset.h lyx-1.2.0_mma/src/mathed/math_stringinset.h
--- lyx-1.2.0/src/mathed/math_stringinset.h	Thu Mar 21 18:42:56 2002
+++ lyx-1.2.0_mma/src/mathed/math_stringinset.h	Wed Jun 26 23:23:21 2002
@@ -44,6 +44,8 @@
 	///
 	void maplize(MapleStream &) const;
 	///
+	void mathematicize(MathematicaStream &) const;
+	///
 	void mathmlize(MathMLStream &) const;
 	///
 	void write(WriteStream & os) const;
diff -u lyx-1.2.0/src/mathed/math_symbolinset.C lyx-1.2.0_mma/src/mathed/math_symbolinset.C
--- lyx-1.2.0/src/mathed/math_symbolinset.C	Thu Mar 21 18:42:56 2002
+++ lyx-1.2.0_mma/src/mathed/math_symbolinset.C	Sun Jun 30 14:35:56 2002
@@ -153,6 +153,13 @@
 		os << name();
 }
 
+void MathSymbolInset::mathematicize(MathematicaStream & os) const
+{
+	if ( name() == "pi")    { os << "Pi"; return;}
+	if ( name() == "infty") { os << "Infinity"; return;}
+	os << name();
+}
+
 
 char const * MathMLtype(string const & s)
 {
diff -u lyx-1.2.0/src/mathed/math_symbolinset.h lyx-1.2.0_mma/src/mathed/math_symbolinset.h
--- lyx-1.2.0/src/mathed/math_symbolinset.h	Fri Feb  1 11:21:29 2002
+++ lyx-1.2.0_mma/src/mathed/math_symbolinset.h	Wed Jun 26 23:04:02 2002
@@ -45,6 +45,8 @@
 	///
 	void maplize(MapleStream &) const;
 	///
+	void mathematicize(MathematicaStream &) const;
+	///
 	void mathmlize(MathMLStream &) const;
 	///
 	void octavize(OctaveStream &) const;
diff -u lyx-1.2.0/src/mathed/math_unknowninset.C lyx-1.2.0_mma/src/mathed/math_unknowninset.C
--- lyx-1.2.0/src/mathed/math_unknowninset.C	Thu Mar 21 18:42:56 2002
+++ lyx-1.2.0_mma/src/mathed/math_unknowninset.C	Thu Jun 27 10:18:48 2002
@@ -75,6 +75,11 @@
 	os << name_;
 }
 
+void MathUnknownInset::mathematicize(MathematicaStream & os) const
+{
+	os << name_;
+}
+
 
 void MathUnknownInset::mathmlize(MathMLStream & os) const
 {
diff -u lyx-1.2.0/src/mathed/math_unknowninset.h lyx-1.2.0_mma/src/mathed/math_unknowninset.h
--- lyx-1.2.0/src/mathed/math_unknowninset.h	Tue Mar 19 17:55:58 2002
+++ lyx-1.2.0_mma/src/mathed/math_unknowninset.h	Thu Jun 27 10:17:59 2002
@@ -36,6 +36,8 @@
 	///
 	void maplize(MapleStream &) const;
 	///
+	void mathematicize(MathematicaStream &) const;
+	///
 	void mathmlize(MathMLStream &) const;
 	///
 	void octavize(OctaveStream &) const;

Reply via email to