cas2html.cc
1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// -*- mode:C++ ; compile-command: "g++ cas2html.cc -o cas2html -lgiac -lgmp" -*-
// g++ --static cas2html.cc -o cas2html -lgiac -lgsl -lgslcblas -lmpfr -lgmp -ldl
// Pour installer sur BSD brandelf -t Linux cas2html
#ifndef IN_GIAC
#include <giac/giac.h>
#include <giac/mathml.h>
#include <giac/tex.h>
#else
#include "giac.h"
#include "mathml.h"
#include "tex.h"
#endif
#include <string>
#include <fstream>
using namespace std;
using namespace giac;
void elimine_inf_sup(string &s){
string t="";
while (t!=s){
t=s;
int i=s.find("<"), j=s.find(">");
if (i!=-1)
s.replace(s.find("<"),1,"<");
if (j!=-1)
s.replace(s.find(">"),1,">");
}
}
int main(int ARGC, char *ARGV[])
{
giac::child_id=1;
bool b_mathml=0, b_text=0, b_latex=0;
string s, t;
gen *g, e;
// recherche des paramètres passés au programme
for (int i=1 ; i<ARGC ; i++) {
if (string(ARGV[i])=="-mathml" || string(ARGV[i])=="-m")
b_mathml=1;
else if (string(ARGV[i])=="-text" || string(ARGV[i])=="-t")
b_text=1;
else if (string(ARGV[i])=="-latex" || string(ARGV[i])=="-l")
b_latex=1;
else {
s=string(ARGV[i]);
g= new gen(s);
e=eval(*g);
if (b_mathml){
t=gen2mathml(e);
s=gen2mathml(*g);
}
else if (b_latex){
t=gen2tex(e);
s=gen2tex(*g);
}
else{
t=e.print();
s=g->print();
}
if (b_text){
elimine_inf_sup(t);
elimine_inf_sup(s);
}
cout<<s<<endl;
cout<<t<<endl;
delete g;
}
}// end for i
}