Rev 8894 | Rev 9618 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8894 | Rev 9568 | ||
---|---|---|---|
Line 39... | Line 39... | ||
39 | } |
39 | } |
40 | else |
40 | else |
41 | { |
41 | { |
42 | pid = fork(); |
42 | pid = fork(); |
43 | if (pid == (pid_t) 0){ |
43 | if (pid == (pid_t) 0){ |
- | 44 | /* |
|
44 |
|
45 | this buffer should probably be set to 0.5 * MAX_LINELEN : mathml is very big ! |
45 |
|
46 | if output mathml string larger ;ERROR will be signaled by wims_mathml. |
- | 47 | */ |
|
46 | char mml_buffer[MAX_LINELEN+1]; |
48 | char mml_buffer[MAX_LINELEN+1]; |
47 | sprintf(mml_buffer, "%d", MAX_LINELEN);// int --> char |
49 | sprintf(mml_buffer, "%d", MAX_LINELEN);// int --> char |
48 |
|
50 | /* setting --tex-size argument to wims_mathml.cc */ |
49 | char mathml_tex_size[64]; |
51 | char mathml_tex_size[64];/*this should be a string like "250%"*/ |
50 | int texsize_list[]={20,30,50,70,90,100,120,130,150,180,220,300}; |
52 | int texsize_list[]={20,30,50,70,90,100,120,130,150,180,220,300}; |
- | 53 | /* |
|
51 |
|
54 | analogue to mathfonts.c but now we talk % and we could make any amount of changes |
52 |
|
55 | not limited by font-size !! |
53 |
|
56 | when math_with_gifs is removed from wims, we can rethink / improve this |
- | 57 | */ |
|
54 | int idx = |
58 | int idx = 5; |
- | 59 | int use_js_zoom = 0; |
|
- | 60 | /* |
|
55 |
|
61 | default js-zoom in mathml if disabled |
56 |
|
62 | enable via adm/light |
57 |
|
63 | next code is stolen from wims.c |
- | 64 | */ |
|
58 | if(getvar("useropts") != NULL || getvar("wims_useropts") != NULL){ |
65 | if(getvar("useropts") != NULL || getvar("wims_useropts") != NULL){ |
59 | char *u; |
66 | char *u; |
- | 67 | u = getvar("useropts"); |
|
60 |
|
68 | /* set via adm/light or via cookie? */ |
61 | if(u == NULL || *u == 0){ u=getvar("wims_useropts");} |
69 | if(u == NULL || *u == 0){ u=getvar("wims_useropts");} /* wims_user? look into def file */ |
62 | if(u != NULL && *u != 0){ |
70 | if(u != NULL && *u != 0){ |
63 | if(myisdigit(u[0])){ |
71 | if(myisdigit(u[0])){ /* 2 digit code : 12,22,32,...,92 [tex_size mathalignbase] */ |
64 | idx = u[0] - '0'; |
72 | idx = u[0] - '0'; |
65 | if(idx < 0 || idx > 11){ idx = |
73 | if(idx < 0 || idx > 11){ idx = 5; } /* the default value 100% */ |
66 | } |
74 | } |
- | 75 | if(myisdigit(u[2]) && u[2]!=0){ |
|
- | 76 | /* |
|
67 |
|
77 | suppose we add 0 or 1 to useropts for using js-zoom on mathml? |
68 |
|
78 | 3 digitcode: 621 == fontsize idx=6 & use mathml & use zoom |
- | 79 | */ |
|
69 | use_js_zoom = u[2] - '0'; |
80 | use_js_zoom = u[2] - '0'; |
70 | if(use_js_zoom > 1 || use_js_zoom < 0){ |
81 | if(use_js_zoom > 1 || use_js_zoom < 0){ |
- | 82 | use_js_zoom = 0; |
|
71 |
|
83 | /* disable js-zooming of mathml */ |
72 | } |
84 | } |
73 | } |
85 | } |
74 | } |
86 | } |
75 | } |
87 | } |
76 | else |
88 | else |
77 | { |
89 | { /* we take the default setting from adm/management config */ |
78 | idx = atoi(getvar("wims_texbasesize")) ; |
90 | idx = atoi(getvar("wims_texbasesize")) ; |
79 | if(idx < 0 || idx > 11){ idx = |
91 | if(idx < 0 || idx > 11){ idx = 5; } /* the default value 100% */ |
80 | } |
92 | } |
- | 93 | /* |
|
81 |
|
94 | check is a module wants to disable zooming (eg drag&drop or others ) |
82 |
|
95 | !set disable_zoom=yes |
83 |
|
96 | if not set: disable_zoom="no"; see config.c |
- | 97 | */ |
|
84 | if( strcmp( getvar("disable_zoom") , "yes" ) == 0 ){ |
98 | if( strcmp( getvar("disable_zoom") , "yes" ) == 0 ){ |
85 | use_js_zoom = 0; |
99 | use_js_zoom = 0; |
86 | } |
100 | } |
87 |
|
101 | /* now write the "char" 100% into variable "mathml_tex_size" */ |
88 | snprintf(mathml_tex_size,sizeof(mathml_tex_size),"%d%%",texsize_list[idx]); |
102 | snprintf(mathml_tex_size,sizeof(mathml_tex_size),"%d%%",texsize_list[idx]); |
89 |
|
103 | /* int --> char : added % sign (needed for mathml) [%% = escaped %] */ |
90 | if(strlen(mathml_tex_size) == 0 ){ // this should not happen |
104 | if(strlen(mathml_tex_size) == 0 ){ // this should not happen |
91 | sprintf(mathml_tex_size,"%s"," |
105 | sprintf(mathml_tex_size,"%s","100%"); |
92 |
|
106 | /* if it goes wrong we set 100% */ |
93 | // default in itex2MML was 110% : but we thought it was too small... ? |
- | |
94 | } |
107 | } |
95 | char zoom[2]; |
108 | char zoom[2]; |
96 | snprintf(zoom, 2 ,"%d",use_js_zoom); |
109 | snprintf(zoom, 2 ,"%d",use_js_zoom);/* int --> char : "0" or "1" */ |
- | 110 | /* |
|
- | 111 | jm.evers 30/9/2015 |
|
- | 112 | ||
- | 113 | FOR TESTING SYNCHRONISATION FONTSIZE HTML--MATHML |
|
- | 114 | SET DEFAULT tex-size = 100 % |
|
- | 115 | and use a |
|
- | 116 | <span style="fonst-size:1em" ><math .. > ... </math></span> |
|
- | 117 | in wims_mathml.y |
|
- | 118 | ||
- | 119 | zooming will be adressed (rewritten) when things are OK !! |
|
- | 120 | since zooming is only interesting in native MathML browsers (FireFox and Gecko family) |
|
- | 121 | the zooming could be prepared in exec.c (where mathjax is included for all other browsers) |
|
- | 122 | by adding a zoom function and mouselistener on span element (wims_mathml.y) |
|
- | 123 | ||
- | 124 | see forum post of Eric Reyssat |
|
- | 125 | http://wimsedu.info/?topic=unites-de-mesure-et-mathml/#post-3105 |
|
- | 126 | ||
- | 127 | */ |
|
97 | char *argv[]={"wims_mathml","--use-zoom",zoom,"--tex-size" |
128 | char *argv[]={"wims_mathml","--use-zoom",zoom,"--tex-size 100%%","--max-mml-size",mml_buffer,"--tex-string",p,NULL}; |
98 | /* This is the child process. Close other end first. */ |
129 | /* This is the child process. Close other end first. */ |
99 | close(my_pipe[0]); |
130 | close(my_pipe[0]); |
100 | dup2(my_pipe[1], 1); |
131 | dup2(my_pipe[1], 1); /* send stdout to the pipe */ |
101 | dup2(my_pipe[1], 2); |
132 | dup2(my_pipe[1], 2); /* send stderr to the pipe */ |
102 | close(my_pipe[1]); |
133 | close(my_pipe[1]); |
103 | execv("../bin/wims_mathml",argv); |
134 | execv("../bin/wims_mathml",argv); |
104 | internal_error("could not execute wims_mathml\n"); |
135 | internal_error("could not execute wims_mathml\n"); |
105 | mathalign_base = 1; |
136 | mathalign_base = 1; |
106 | return 0; |
137 | return 0; /* go to insmath with gifs ! */ |
107 | } |
138 | } |
108 | else |
139 | else |
109 | { |
140 | { |
110 | if (pid < (pid_t) 0){ |
141 | if (pid < (pid_t) 0){ |
111 | close(my_pipe[0]); |
142 | close(my_pipe[0]); /* close the read end of the pipe in the parent */ |
112 | close(my_pipe[1]); |
143 | close(my_pipe[1]); /* close the write end of the pipe in the parent */ |
113 | internal_error("mathml(): fork() failure.\n"); |
144 | internal_error("mathml(): fork() failure.\n"); |
114 | mathalign_base = 1; |
145 | mathalign_base = 1; |
115 | return 0; |
146 | return 0; /* go to insmath with gifs */ |
116 | } |
147 | } |
117 | else |
148 | else |
118 | { |
149 | { |
119 | int status; |
150 | int status; |
120 | FILE *stream; |
151 | FILE *stream; |
121 | close(my_pipe[1]); |
152 | close(my_pipe[1]); /* close the write end of the pipe in the parent */ |
122 | stream = fdopen (my_pipe[0], "r"); |
153 | stream = fdopen (my_pipe[0], "r"); |
123 | char buffer[MAX_LINELEN+1]; |
154 | char buffer[MAX_LINELEN+1]; |
124 |
|
155 | /* make buffer filled with 'zero/null' */ |
125 | memset(buffer,'\0',MAX_LINELEN); |
156 | memset(buffer,'\0',MAX_LINELEN); /* or use bzero(buffer,maxsize); */ |
126 | /* read output from program line by line */ |
157 | /* read output from program line by line */ |
127 | if (option == 1) { |
158 | if (option == 1) { |
128 | *p=0; |
159 | *p=0; |
129 | while ( fgets(buffer, MAX_LINELEN, stream) != NULL ){ |
160 | while ( fgets(buffer, MAX_LINELEN, stream) != NULL ){ |
130 | if(strcmp(buffer,"ERROR") != 0){ |
161 | if(strcmp(buffer,"ERROR") != 0){ |
131 | mystrncpy(p, buffer, MAX_LINELEN-1); |
162 | mystrncpy(p, buffer, MAX_LINELEN-1); |