1 (* Copyright (C) 2000, HELM Team.
3 * This file is part of HELM, an Hypertextual, Electronic
4 * Library of Mathematics, developed at the Computer Science
5 * Department, University of Bologna, Italy.
7 * HELM is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * HELM is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with HELM; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 * For details, see the HELM World-Wide-Web page,
23 * http://cs.unibo.it/helm/.
26 (**************************************************************************)
30 (* Andrea Asperti <asperti@cs.unibo.it> *)
33 (**************************************************************************)
41 | Mtext of attr * string
44 | Mgliph of attr * string
45 (* General Layout Schemata *)
46 | Mrow of attr * mpres list
47 | Mfrac of attr * mpres * mpres
48 | Msqrt of attr * mpres
49 | Mroot of attr * mpres * mpres
50 | Mstyle of attr * mpres
51 | Merror of attr * mpres
52 | Mpadded of attr * mpres
53 | Mphantom of attr * mpres
54 | Mfenced of attr * mpres list
55 | Menclose of attr * mpres
56 (* Script and Limit Schemata *)
57 | Msub of attr * mpres * mpres
58 | Msup of attr * mpres * mpres
59 | Msubsup of attr * mpres * mpres *mpres
60 | Munder of attr * mpres * mpres
61 | Mover of attr * mpres * mpres
62 | Munderover of attr * mpres * mpres *mpres
63 (* | Multiscripts of ??? NOT IMPLEMEMENTED *)
64 (* Tables and Matrices *)
65 | Mtable of attr * row list
66 (* Enlivening Expressions *)
67 | Maction of attr * mpres list
71 row = Mtr of attr * mtd list
75 mtd = Mtd of attr * mpres
79 attr = (string * string) list
83 let smallskip = Mspace([("width","0.1cm")]);;
84 let indentation = Mspace([("width","0.3cm")]);;
87 Mrow([],[indentation;elem]);;
89 let standard_tbl_attr =
90 [("align","baseline 1");("equalrows","false");("columnalign","left")];;
92 let two_rows_table attr a b =
93 Mtable(attr@standard_tbl_attr,
95 Mtr([],[Mtd([],b)])]);;
97 let two_rows_table_with_brackets attr a b op =
98 (* only the open bracket is added; the closed bracket must be in b *)
99 Mtable(attr@standard_tbl_attr,
100 [Mtr([],[Mtd([],Mrow([],[Mtext([],"(");a]))]);
101 Mtr([],[Mtd([],Mrow([],[indentation;op;smallskip;b]))])]);;
103 let two_rows_table_without_brackets attr a b op =
104 Mtable(attr@standard_tbl_attr,
105 [Mtr([],[Mtd([],a)]);
106 Mtr([],[Mtd([],Mrow([],[indentation;op;smallskip;b]))])]);;
108 let row_with_brackets attr a b op =
109 (* by analogy with two_rows_table_with_brackets we only add the
111 Mrow(attr,[Mtext([],"(");a;smallskip;op;smallskip;b])
113 let row_without_brackets attr a b op =
114 Mrow(attr,[a;smallskip;op;smallskip;b])
116 let rec print_mpres =
117 let module X = Xml in
119 Mi (attr,s) -> X.xml_nempty "mi" attr (X.xml_cdata s)
120 | Mn (attr,s) -> X.xml_nempty "mn" attr (X.xml_cdata s)
121 | Mo (attr,s) -> X.xml_nempty "mo" attr (X.xml_cdata s)
122 | Mtext (attr,s) -> X.xml_nempty "mtext" attr (X.xml_cdata s)
123 | Mspace attr -> X.xml_empty "mspace" attr
124 | Ms (attr,s) -> X.xml_nempty "ms" attr (X.xml_cdata s)
125 | Mgliph (attr,s) -> X.xml_nempty "mgliph" attr (X.xml_cdata s)
126 (* General Layout Schemata *)
128 X.xml_nempty "mrow" attr
129 [< (List.fold_right (fun x i -> [< (print_mpres x) ; i >]) l [<>])
131 | Mfrac (attr,m1,m2) ->
132 X.xml_nempty "mfrac" attr
137 X.xml_nempty "msqrt" attr [< print_mpres m >]
138 | Mroot (attr,m1,m2) ->
139 X.xml_nempty "mroot" attr
144 X.xml_nempty "mstyle" attr [< print_mpres m >]
146 X.xml_nempty "merror" attr [< print_mpres m >]
147 | Mpadded (attr,m) ->
148 X.xml_nempty "mpadded" attr [< print_mpres m >]
149 | Mphantom (attr,m) ->
150 X.xml_nempty "mphantom" attr [< print_mpres m >]
151 | Mfenced (attr,l) ->
152 X.xml_nempty "mfenced" attr
153 [< (List.fold_right (fun x i -> [< (print_mpres x) ; i >]) l [<>])
155 | Menclose (attr,m) ->
156 X.xml_nempty "menclose" attr [< print_mpres m >]
157 (* Script and Limit Schemata *)
158 | Msub (attr,m1,m2) ->
159 X.xml_nempty "msub" attr
163 | Msup (attr,m1,m2) ->
164 X.xml_nempty "msup" attr
168 | Msubsup (attr,m1,m2,m3) ->
169 X.xml_nempty "msubsup" attr
174 | Munder (attr,m1,m2) ->
175 X.xml_nempty "munder" attr
179 | Mover (attr,m1,m2) ->
180 X.xml_nempty "mover" attr
184 | Munderover (attr,m1,m2,m3) ->
185 X.xml_nempty "munderover" attr
190 (* | Multiscripts of ??? NOT IMPLEMEMENTED *)
191 (* Tables and Matrices *)
192 | Mtable (attr, rl) ->
193 X.xml_nempty "mtable" attr
194 [< (List.fold_right (fun x i -> [< (print_mrow x) ; i >]) rl [<>])
196 (* Enlivening Expressions *)
197 | Maction (attr, l) ->
198 X.xml_nempty "maction" attr
199 [< (List.fold_right (fun x i -> [< (print_mpres x) ; i >]) l [<>])
203 let module X = Xml in
206 X.xml_nempty "mtr" attr
207 [< (List.fold_right (fun x i -> [< (print_mtd x) ; i >]) l [<>])
211 let module X = Xml in
213 Mtd (attr,m) -> X.xml_nempty "mtd" attr (print_mpres m)