93 | "\\<threequarters>" => (1.0, "¾") |
93 | "\\<threequarters>" => (1.0, "¾") |
94 | "\\<questiondown>" => (1.0, "¿") |
94 | "\\<questiondown>" => (1.0, "¿") |
95 | "\\<times>" => (1.0, "×") |
95 | "\\<times>" => (1.0, "×") |
96 | "\\<emptyset>" => (1.0, "Ø") |
96 | "\\<emptyset>" => (1.0, "Ø") |
97 | "\\<div>" => (1.0, "÷") |
97 | "\\<div>" => (1.0, "÷") |
98 | "\\<circ>" => (1.0, "ˆ") |
98 | "\\<circ>" => (1.0, "ˆ") |
99 | "\\<Alpha>" => (1.0, "Α") |
99 | "\\<Alpha>" => (1.0, "Α") |
100 | "\\<Beta>" => (1.0, "Β") |
100 | "\\<Beta>" => (1.0, "Β") |
101 | "\\<Gamma>" => (1.0, "Γ") |
101 | "\\<Gamma>" => (1.0, "Γ") |
102 | "\\<Delta>" => (1.0, "Δ") |
102 | "\\<Delta>" => (1.0, "Δ") |
103 | "\\<Epsilon>" => (1.0, "Ε") |
103 | "\\<Epsilon>" => (1.0, "Ε") |
160 | "\\<Sum>" => (1.0, "∑") |
160 | "\\<Sum>" => (1.0, "∑") |
161 | "\\<star>" => (1.0, "∗") |
161 | "\\<star>" => (1.0, "∗") |
162 | "\\<propto>" => (1.0, "∝") |
162 | "\\<propto>" => (1.0, "∝") |
163 | "\\<infinity>" => (1.0, "∞") |
163 | "\\<infinity>" => (1.0, "∞") |
164 | "\\<angle>" => (1.0, "∠") |
164 | "\\<angle>" => (1.0, "∠") |
165 | "\\<and>" => (1.0, "∧") |
165 | "\\<and>" => (1.0, "∧") |
166 | "\\<or>" => (1.0, "∨") |
166 | "\\<or>" => (1.0, "∨") |
167 | "\\<inter>" => (1.0, "∩") |
167 | "\\<inter>" => (1.0, "∩") |
168 | "\\<union>" => (1.0, "∪") |
168 | "\\<union>" => (1.0, "∪") |
169 | "\\<sim>" => (1.0, "∼") |
169 | "\\<sim>" => (1.0, "∼") |
170 | "\\<cong>" => (1.0, "≅") |
170 | "\\<cong>" => (1.0, "≅") |
189 | "\\<lozenge>" => (1.0, "◊") |
189 | "\\<lozenge>" => (1.0, "◊") |
190 | "\\<spadesuit>" => (1.0, "♠") |
190 | "\\<spadesuit>" => (1.0, "♠") |
191 | "\\<clubsuit>" => (1.0, "♣") |
191 | "\\<clubsuit>" => (1.0, "♣") |
192 | "\\<heartsuit>" => (1.0, "♥") |
192 | "\\<heartsuit>" => (1.0, "♥") |
193 | "\\<diamondsuit>" => (1.0, "♦") |
193 | "\\<diamondsuit>" => (1.0, "♦") |
194 |
|
195 | "\\<lbrakk>" => (2.0, "[|") |
194 | "\\<lbrakk>" => (2.0, "[|") |
196 | "\\<rbrakk>" => (2.0, "|]") |
195 | "\\<rbrakk>" => (2.0, "|]") |
197 | "\\<Longrightarrow>" => (3.0, "==>") |
196 | "\\<Longrightarrow>" => (3.0, "==>") |
198 | "\\<Rightarrow>" => (3.0, "=>") |
197 | "\\<Rightarrow>" => (2.0, "=>") |
199 | "\\<And>" => (2.0, "!!") |
198 | "\\<And>" => (2.0, "!!") |
200 | "\\<Colon>" => (2.0, "::") |
199 | "\\<Colon>" => (2.0, "::") |
201 | "\\<lparr>" => (2.0, "(|") |
200 | "\\<lparr>" => (2.0, "(|") |
202 | "\\<rparr>" => (2.0, "|)") |
201 | "\\<rparr>" => (2.0, "|)") |
203 | "\\<longleftrightarrow>" => (3.0, "<->") |
202 | "\\<longleftrightarrow>" => (3.0, "<->") |
204 | "\\<longrightarrow>" => (3.0, "-->") |
203 | "\\<longrightarrow>" => (3.0, "-->") |
205 | "\\<rightarrow>" => (2.0, "->") |
204 | "\\<rightarrow>" => (2.0, "->") |
206 | "\\<rightleftharpoons>" => (2.0, "==") |
|
207 | "\\<rightharpoonup>" => (2.0, "=>") |
|
208 | "\\<leftharpoondown>" => (2.0, "<=") |
|
209 |
|
210 | "\\<^bsub>" => (0.0, "<sub>") |
205 | "\\<^bsub>" => (0.0, "<sub>") |
211 | "\\<^esub>" => (0.0, "</sub>") |
206 | "\\<^esub>" => (0.0, "</sub>") |
212 | "\\<^bsup>" => (0.0, "<sup>") |
207 | "\\<^bsup>" => (0.0, "<sup>") |
213 | "\\<^esup>" => (0.0, "</sup>") |
208 | "\\<^esup>" => (0.0, "</sup>") |
214 (* keep \<^sub> etc, so they are not destroyed by default case *) |
209 | "\\<^sub>" => (0.0, "\\<^sub>") |
215 | "\\<^sup>" => (0.0, "\\<^sup>") |
210 | "\\<^sup>" => (0.0, "\\<^sup>") |
216 | "\\<^sub>" => (0.0, "\\<^sub>") |
211 | "\\<^isub>" => (0.0, "\\<^isub>") |
217 | "\\<^isup>" => (0.0, "\\<^isup>") |
212 | "\\<^isup>" => (0.0, "\\<^isup>") |
218 | "\\<^isub>" => (0.0, "\\<^isub>") |
|
219 | s => (real (size s), implode (map escape (explode s))); |
213 | s => (real (size s), implode (map escape (explode s))); |
220 |
214 |
221 fun add_sym (width, (w: real, s)) = (width + w, s); |
215 fun add_sym (width, (w: real, s)) = (width + w, s); |
222 |
216 |
223 fun script (0, "\\<^sub>") = (1,"<sub>") |
217 fun script (0, "\\<^sub>") = (1, "<sub>") |
224 | script (0, "\\<^isub>") = (1,"<sub>") |
218 | script (0, "\\<^isub>") = (1, "<sub>") |
225 | script (1, x) = (0, x ^ "</sub>") |
219 | script (1, x) = (0, x ^ "</sub>") |
226 | script (0, "\\<^sup>") = (2,"<sup>") |
220 | script (0, "\\<^sup>") = (2, "<sup>") |
227 | script (0, "\\<^isup>") = (2,"<sup>") |
221 | script (0, "\\<^isup>") = (2, "<sup>") |
228 | script (2, x) = (0, x ^ "</sup>") |
222 | script (2, x) = (0, x ^ "</sup>") |
229 | script (s, x) = (s,x); |
223 | script (s, x) = (s, x); |
230 |
224 |
231 fun scrs (s, []) = (s,[]) |
225 fun scripts ss = #2 (foldl_map script (0, ss)); |
232 | scrs (s, x::xs) = let val (s', x') = script (s, x) |
|
233 val (s'', xs') = scrs (s', xs) |
|
234 in (s'', x'::xs') end; |
|
235 |
|
236 fun scripts ss = #2 (scrs (0,ss)); |
|
237 in |
226 in |
238 |
227 |
239 fun output_width str = |
228 fun output_width str = |
240 if not (exists_string (equal "<" orf equal ">" orf equal "&") str) then (str, real (size str)) |
229 if not (exists_string (equal "<" orf equal ">" orf equal "&") str) |
|
230 then (str, real (size str)) |
241 else |
231 else |
242 let val (width, syms) = foldl_map add_sym (0.0, map output_sym (Symbol.explode str)) |
232 let val (width, syms) = foldl_map add_sym (0.0, map output_sym (Symbol.explode str)) |
243 in (implode (scripts syms), width) end; |
233 in (implode (scripts syms), width) end; |
244 |
234 |
245 val output = #1 o output_width; |
235 val output = #1 o output_width; |
246 val output_symbols = scripts o (map (#2 o output_sym)) |
236 val output_symbols = scripts o map (#2 o output_sym); |
247 |
237 |
248 end; |
238 end; |
249 |
239 |
250 |
240 |
251 val _ = Symbol.add_mode htmlN (output_width, Symbol.default_indent); |
241 val _ = Symbol.add_mode htmlN (output_width, Symbol.default_indent); |