author | wenzelm |
Sat, 29 May 2004 15:08:08 +0200 | |
changeset 14839 | c994f1c57fc7 |
parent 14775 | 65c22319829f |
child 14973 | 0613f64653b7 |
permissions | -rw-r--r-- |
6324 | 1 |
(* Title: Pure/Thy/HTML.ML |
2 |
ID: $Id$ |
|
9415 | 3 |
Author: Markus Wenzel and Stefan Berghofer, TU Muenchen |
8808 | 4 |
License: GPL (GNU GENERAL PUBLIC LICENSE) |
6324 | 5 |
|
9415 | 6 |
HTML presentation elements. |
6324 | 7 |
*) |
8 |
||
9 |
signature HTML = |
|
10 |
sig |
|
11 |
val output: string -> string |
|
12 |
val output_width: string -> string * real |
|
13 |
type text (* = string *) |
|
14 |
val plain: string -> text |
|
15 |
val name: string -> text |
|
16 |
val keyword: string -> text |
|
17 |
val file_name: string -> text |
|
6649 | 18 |
val file_path: Url.T -> text |
6324 | 19 |
val href_name: string -> text -> text |
6649 | 20 |
val href_path: Url.T -> text -> text |
6376 | 21 |
val href_opt_name: string option -> text -> text |
6649 | 22 |
val href_opt_path: Url.T option -> text -> text |
6376 | 23 |
val para: text -> text |
6324 | 24 |
val preform: text -> text |
25 |
val verbatim: string -> text |
|
7725 | 26 |
val begin_index: Url.T * string -> Url.T * string -> Url.T option |
27 |
-> Url.T option -> Url.T -> text |
|
6338 | 28 |
val end_index: text |
9415 | 29 |
val applet_pages: string -> Url.T * string -> (string * string) list |
6649 | 30 |
val theory_entry: Url.T * string -> text |
31 |
val session_entries: (Url.T * string) list -> text |
|
8190 | 32 |
val verbatim_source: Symbol.symbol list -> text |
6649 | 33 |
val begin_theory: Url.T * string -> string -> (Url.T option * string) list -> |
7408 | 34 |
(Url.T option * Url.T * bool option) list -> text -> text |
6324 | 35 |
val end_theory: text |
6649 | 36 |
val ml_file: Url.T -> string -> text |
13531 | 37 |
val results: string -> (string * thm list) list -> text |
8088 | 38 |
val chapter: string -> text |
6324 | 39 |
val section: string -> text |
7634 | 40 |
val subsection: string -> text |
41 |
val subsubsection: string -> text |
|
6324 | 42 |
val setup: (theory -> theory) list |
43 |
end; |
|
44 |
||
45 |
structure HTML: HTML = |
|
46 |
struct |
|
47 |
||
48 |
||
49 |
(** HTML print modes **) |
|
50 |
||
51 |
(* mode *) |
|
52 |
||
53 |
val htmlN = "HTML"; |
|
10573 | 54 |
fun html_mode f x = setmp print_mode (htmlN :: ! print_mode) f x; |
6324 | 55 |
|
56 |
||
57 |
(* symbol output *) |
|
58 |
||
6338 | 59 |
local |
60 |
val escape = fn "<" => "<" | ">" => ">" | "&" => "&" | c => c; |
|
6324 | 61 |
|
6338 | 62 |
val output_sym = |
9963 | 63 |
fn "\\<spacespace>" => (2.0, " ") |
64 |
| "\\<exclamdown>" => (1.0, "¡") |
|
65 |
| "\\<cent>" => (1.0, "¢") |
|
66 |
| "\\<pounds>" => (1.0, "£") |
|
67 |
| "\\<currency>" => (1.0, "¤") |
|
68 |
| "\\<yen>" => (1.0, "¥") |
|
69 |
| "\\<bar>" => (1.0, "¦") |
|
70 |
| "\\<section>" => (1.0, "§") |
|
10837
7d640de604e4
added \<dieresis>, \<acute>, \<cedilla>, \<emptyset>;
wenzelm
parents:
10831
diff
changeset
|
71 |
| "\\<dieresis>" => (1.0, "¨") |
9963 | 72 |
| "\\<copyright>" => (1.0, "©") |
73 |
| "\\<ordfeminine>" => (1.0, "ª") |
|
74 |
| "\\<guillemotleft>" => (1.0, "«") |
|
75 |
| "\\<not>" => (1.0, "¬") |
|
6338 | 76 |
| "\\<hyphen>" => (1.0, "­") |
9963 | 77 |
| "\\<registered>" => (1.0, "®") |
10831 | 78 |
| "\\<inverse>" => (1.0, "¯") |
9963 | 79 |
| "\\<degree>" => (1.0, "°") |
80 |
| "\\<plusminus>" => (1.0, "±") |
|
81 |
| "\\<twosuperior>" => (1.0, "²") |
|
82 |
| "\\<threesuperior>" => (1.0, "³") |
|
10837
7d640de604e4
added \<dieresis>, \<acute>, \<cedilla>, \<emptyset>;
wenzelm
parents:
10831
diff
changeset
|
83 |
| "\\<acute>" => (1.0, "´") |
9963 | 84 |
| "\\<paragraph>" => (1.0, "¶") |
6338 | 85 |
| "\\<cdot>" => (1.0, "·") |
10837
7d640de604e4
added \<dieresis>, \<acute>, \<cedilla>, \<emptyset>;
wenzelm
parents:
10831
diff
changeset
|
86 |
| "\\<cedilla>" => (1.0, "¸") |
9963 | 87 |
| "\\<onesuperior>" => (1.0, "¹") |
88 |
| "\\<ordmasculine>" => (1.0, "º") |
|
89 |
| "\\<guillemotright>" => (1.0, "»") |
|
90 |
| "\\<onequarter>" => (1.0, "¼") |
|
91 |
| "\\<onehalf>" => (1.0, "½") |
|
92 |
| "\\<threequarters>" => (1.0, "¾") |
|
93 |
| "\\<questiondown>" => (1.0, "¿") |
|
6338 | 94 |
| "\\<times>" => (1.0, "×") |
9963 | 95 |
| "\\<div>" => (1.0, "÷") |
14571 | 96 |
| "\\<circ>" => (1.0, "ˆ") |
14552 | 97 |
| "\\<Alpha>" => (1.0, "Α") |
98 |
| "\\<Beta>" => (1.0, "Β") |
|
99 |
| "\\<Gamma>" => (1.0, "Γ") |
|
100 |
| "\\<Delta>" => (1.0, "Δ") |
|
101 |
| "\\<Epsilon>" => (1.0, "Ε") |
|
102 |
| "\\<Zeta>" => (1.0, "Ζ") |
|
103 |
| "\\<Eta>" => (1.0, "Η") |
|
104 |
| "\\<Theta>" => (1.0, "Θ") |
|
105 |
| "\\<Iota>" => (1.0, "Ι") |
|
106 |
| "\\<Kappa>" => (1.0, "Κ") |
|
107 |
| "\\<Lambda>" => (1.0, "Λ") |
|
108 |
| "\\<Mu>" => (1.0, "Μ") |
|
109 |
| "\\<Nu>" => (1.0, "Ν") |
|
110 |
| "\\<Xi>" => (1.0, "Ξ") |
|
111 |
| "\\<Omicron>" => (1.0, "Ο") |
|
112 |
| "\\<Pi>" => (1.0, "Π") |
|
113 |
| "\\<Rho>" => (1.0, "Ρ") |
|
114 |
| "\\<Sigma>" => (1.0, "Σ") |
|
115 |
| "\\<Tau>" => (1.0, "Τ") |
|
116 |
| "\\<Upsilon>" => (1.0, "Υ") |
|
117 |
| "\\<Phi>" => (1.0, "Φ") |
|
118 |
| "\\<Chi>" => (1.0, "Χ") |
|
119 |
| "\\<Psi>" => (1.0, "Ψ") |
|
120 |
| "\\<Omega>" => (1.0, "Ω") |
|
121 |
| "\\<alpha>" => (1.0, "α") |
|
122 |
| "\\<beta>" => (1.0, "β") |
|
123 |
| "\\<gamma>" => (1.0, "γ") |
|
124 |
| "\\<delta>" => (1.0, "δ") |
|
125 |
| "\\<epsilon>" => (1.0, "ε") |
|
126 |
| "\\<zeta>" => (1.0, "ζ") |
|
127 |
| "\\<eta>" => (1.0, "η") |
|
128 |
| "\\<theta>" => (1.0, "ϑ") |
|
129 |
| "\\<iota>" => (1.0, "ι") |
|
130 |
| "\\<kappa>" => (1.0, "κ") |
|
131 |
| "\\<lambda>" => (1.0, "λ") |
|
132 |
| "\\<mu>" => (1.0, "μ") |
|
133 |
| "\\<nu>" => (1.0, "ν") |
|
134 |
| "\\<xi>" => (1.0, "ξ") |
|
135 |
| "\\<omicron>" => (1.0, "ο") |
|
136 |
| "\\<pi>" => (1.0, "π") |
|
137 |
| "\\<rho>" => (1.0, "ρ") |
|
138 |
| "\\<sigma>" => (1.0, "σ") |
|
139 |
| "\\<tau>" => (1.0, "τ") |
|
140 |
| "\\<upsilon>" => (1.0, "υ") |
|
141 |
| "\\<phi>" => (1.0, "φ") |
|
142 |
| "\\<chi>" => (1.0, "χ") |
|
143 |
| "\\<psi>" => (1.0, "ψ") |
|
144 |
| "\\<omega>" => (1.0, "ω") |
|
145 |
| "\\<buller>" => (1.0, "•") |
|
146 |
| "\\<dots>" => (1.0, "…") |
|
147 |
| "\\<Re>" => (1.0, "ℜ") |
|
148 |
| "\\<Im>" => (1.0, "ℑ") |
|
149 |
| "\\<wp>" => (1.0, "℘") |
|
150 |
| "\\<forall>" => (1.0, "∀") |
|
151 |
| "\\<partial>" => (1.0, "∂") |
|
152 |
| "\\<exists>" => (1.0, "∃") |
|
153 |
| "\\<emptyset>" => (1.0, "∅") |
|
154 |
| "\\<nabla>" => (1.0, "∇") |
|
155 |
| "\\<in>" => (1.0, "∈") |
|
156 |
| "\\<notin>" => (1.0, "∉") |
|
14565 | 157 |
| "\\<Prod>" => (1.0, "∏") |
158 |
| "\\<Sum>" => (1.0, "∑") |
|
14552 | 159 |
| "\\<star>" => (1.0, "∗") |
160 |
| "\\<propto>" => (1.0, "∝") |
|
161 |
| "\\<infinity>" => (1.0, "∞") |
|
162 |
| "\\<angle>" => (1.0, "∠") |
|
14571 | 163 |
| "\\<and>" => (1.0, "∧") |
14552 | 164 |
| "\\<or>" => (1.0, "∨") |
165 |
| "\\<inter>" => (1.0, "∩") |
|
166 |
| "\\<union>" => (1.0, "∪") |
|
167 |
| "\\<sim>" => (1.0, "∼") |
|
168 |
| "\\<cong>" => (1.0, "≅") |
|
169 |
| "\\<approx>" => (1.0, "≈") |
|
170 |
| "\\<noteq>" => (1.0, "≠") |
|
171 |
| "\\<equiv>" => (1.0, "≡") |
|
172 |
| "\\<le>" => (1.0, "≤") |
|
173 |
| "\\<ge>" => (1.0, "≥") |
|
174 |
| "\\<subset>" => (1.0, "⊂") |
|
175 |
| "\\<supset>" => (1.0, "⊃") |
|
176 |
| "\\<subseteq>" => (1.0, "⊆") |
|
177 |
| "\\<supseteq>" => (1.0, "⊇") |
|
178 |
| "\\<oplus>" => (1.0, "⊕") |
|
179 |
| "\\<otimes>" => (1.0, "⊗") |
|
180 |
| "\\<bottom>" => (1.0, "⊥") |
|
181 |
| "\\<lceil>" => (1.0, "⌈") |
|
182 |
| "\\<rceil>" => (1.0, "⌉") |
|
183 |
| "\\<lfloor>" => (1.0, "⌊") |
|
184 |
| "\\<rfloor>" => (1.0, "⌋") |
|
185 |
| "\\<langle>" => (1.0, "⟨") |
|
186 |
| "\\<rangle>" => (1.0, "⟩") |
|
187 |
| "\\<lozenge>" => (1.0, "◊") |
|
188 |
| "\\<spadesuit>" => (1.0, "♠") |
|
189 |
| "\\<clubsuit>" => (1.0, "♣") |
|
190 |
| "\\<heartsuit>" => (1.0, "♥") |
|
191 |
| "\\<diamondsuit>" => (1.0, "♦") |
|
192 |
| "\\<lbrakk>" => (2.0, "[|") |
|
193 |
| "\\<rbrakk>" => (2.0, "|]") |
|
194 |
| "\\<Longrightarrow>" => (3.0, "==>") |
|
14571 | 195 |
| "\\<Rightarrow>" => (2.0, "=>") |
14552 | 196 |
| "\\<And>" => (2.0, "!!") |
197 |
| "\\<Colon>" => (2.0, "::") |
|
198 |
| "\\<lparr>" => (2.0, "(|") |
|
199 |
| "\\<rparr>" => (2.0, "|)") |
|
200 |
| "\\<longleftrightarrow>" => (3.0, "<->") |
|
201 |
| "\\<longrightarrow>" => (3.0, "-->") |
|
202 |
| "\\<rightarrow>" => (2.0, "->") |
|
14534 | 203 |
| "\\<^bsub>" => (0.0, "<sub>") |
204 |
| "\\<^esub>" => (0.0, "</sub>") |
|
205 |
| "\\<^bsup>" => (0.0, "<sup>") |
|
206 |
| "\\<^esup>" => (0.0, "</sup>") |
|
14571 | 207 |
| "\\<^sub>" => (0.0, "\\<^sub>") |
14534 | 208 |
| "\\<^sup>" => (0.0, "\\<^sup>") |
14571 | 209 |
| "\\<^isub>" => (0.0, "\\<^isub>") |
14534 | 210 |
| "\\<^isup>" => (0.0, "\\<^isup>") |
14839
c994f1c57fc7
handle raw symbols; Output.add_mode; more robust handling of sub/superscript;
wenzelm
parents:
14775
diff
changeset
|
211 |
| s => |
c994f1c57fc7
handle raw symbols; Output.add_mode; more robust handling of sub/superscript;
wenzelm
parents:
14775
diff
changeset
|
212 |
if Symbol.is_raw s then (1.0, Symbol.decode_raw s) |
c994f1c57fc7
handle raw symbols; Output.add_mode; more robust handling of sub/superscript;
wenzelm
parents:
14775
diff
changeset
|
213 |
else (real (size s), implode (map escape (explode s))); |
6324 | 214 |
|
6338 | 215 |
fun add_sym (width, (w: real, s)) = (width + w, s); |
14534 | 216 |
|
14571 | 217 |
fun script (0, "\\<^sub>") = (1, "<sub>") |
218 |
| script (0, "\\<^isub>") = (1, "<sub>") |
|
219 |
| script (0, "\\<^sup>") = (2, "<sup>") |
|
220 |
| script (0, "\\<^isup>") = (2, "<sup>") |
|
14839
c994f1c57fc7
handle raw symbols; Output.add_mode; more robust handling of sub/superscript;
wenzelm
parents:
14775
diff
changeset
|
221 |
| script (0, x) = (0, x) |
c994f1c57fc7
handle raw symbols; Output.add_mode; more robust handling of sub/superscript;
wenzelm
parents:
14775
diff
changeset
|
222 |
| script (1, x) = (0, x ^ "</sub>") |
c994f1c57fc7
handle raw symbols; Output.add_mode; more robust handling of sub/superscript;
wenzelm
parents:
14775
diff
changeset
|
223 |
| script (2, x) = (0, x ^ "</sup>"); |
14534 | 224 |
|
14839
c994f1c57fc7
handle raw symbols; Output.add_mode; more robust handling of sub/superscript;
wenzelm
parents:
14775
diff
changeset
|
225 |
fun scripts ss = #2 (foldl_map script (0, ss @ [""])); |
6338 | 226 |
in |
6324 | 227 |
|
6338 | 228 |
fun output_width str = |
14571 | 229 |
if not (exists_string (equal "<" orf equal ">" orf equal "&") str) |
230 |
then (str, real (size str)) |
|
6338 | 231 |
else |
232 |
let val (width, syms) = foldl_map add_sym (0.0, map output_sym (Symbol.explode str)) |
|
14534 | 233 |
in (implode (scripts syms), width) end; |
6338 | 234 |
|
235 |
val output = #1 o output_width; |
|
14571 | 236 |
val output_symbols = scripts o map (#2 o output_sym); |
6338 | 237 |
|
238 |
end; |
|
239 |
||
6324 | 240 |
|
14839
c994f1c57fc7
handle raw symbols; Output.add_mode; more robust handling of sub/superscript;
wenzelm
parents:
14775
diff
changeset
|
241 |
val _ = Output.add_mode htmlN (output_width, Symbol.default_indent, Symbol.default_raw); |
6324 | 242 |
|
243 |
||
244 |
(* token translations *) |
|
245 |
||
14541 | 246 |
fun style stl = |
14598
7009f59711e3
Replaced quote by Library.quote, since quote now refers to Symbol.quote
berghofe
parents:
14571
diff
changeset
|
247 |
apfst (enclose ("<span class=" ^ Library.quote stl ^ ">") "</span>") o output_width; |
6324 | 248 |
|
249 |
val html_trans = |
|
14541 | 250 |
[("class", style "tclass"), |
251 |
("tfree", style "tfree"), |
|
252 |
("tvar", style "tvar"), |
|
253 |
("free", style "free"), |
|
254 |
("bound", style "bound"), |
|
255 |
("var", style "var"), |
|
256 |
("xstr", style "xstr")]; |
|
6324 | 257 |
|
258 |
||
259 |
||
260 |
(** HTML markup **) |
|
261 |
||
262 |
type text = string; |
|
263 |
||
264 |
||
265 |
(* atoms *) |
|
266 |
||
267 |
val plain = output; |
|
14541 | 268 |
fun name s = "<span class=\"name\">" ^ output s ^ "</span>"; |
269 |
fun keyword s = "<span class=\"keyword\">" ^ output s ^ "</span>"; |
|
270 |
fun file_name s = "<span class=\"filename\">" ^ output s ^ "</span>"; |
|
6649 | 271 |
val file_path = file_name o Url.pack; |
6324 | 272 |
|
273 |
||
274 |
(* misc *) |
|
275 |
||
14598
7009f59711e3
Replaced quote by Library.quote, since quote now refers to Symbol.quote
berghofe
parents:
14571
diff
changeset
|
276 |
fun href_name s txt = "<a href=" ^ Library.quote s ^ ">" ^ txt ^ "</a>"; |
6649 | 277 |
fun href_path path txt = href_name (Url.pack path) txt; |
6376 | 278 |
|
279 |
fun href_opt_name None txt = txt |
|
280 |
| href_opt_name (Some s) txt = href_name s txt; |
|
281 |
||
282 |
fun href_opt_path None txt = txt |
|
283 |
| href_opt_path (Some p) txt = href_path p txt; |
|
284 |
||
12413 | 285 |
fun para txt = "\n<p>" ^ txt ^ "</p>\n"; |
6324 | 286 |
fun preform txt = "<pre>" ^ txt ^ "</pre>"; |
287 |
val verbatim = preform o output; |
|
288 |
||
289 |
||
290 |
(* document *) |
|
291 |
||
292 |
fun begin_document title = |
|
14083
aed5d25c4a0c
Added DOCTYPE and Content-type to HTML documents.
webertj
parents:
13531
diff
changeset
|
293 |
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n\ |
aed5d25c4a0c
Added DOCTYPE and Content-type to HTML documents.
webertj
parents:
13531
diff
changeset
|
294 |
\\n\ |
aed5d25c4a0c
Added DOCTYPE and Content-type to HTML documents.
webertj
parents:
13531
diff
changeset
|
295 |
\<html>\n\ |
6405 | 296 |
\<head>\n\ |
14083
aed5d25c4a0c
Added DOCTYPE and Content-type to HTML documents.
webertj
parents:
13531
diff
changeset
|
297 |
\<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n\ |
6405 | 298 |
\<title>" ^ plain (title ^ " (" ^ version ^ ")") ^ "</title>\n\ |
14541 | 299 |
\<link rel=\"stylesheet\" type=\"text/css\" href=\"isabelle.css\">\n\ |
6405 | 300 |
\</head>\n\ |
301 |
\\n\ |
|
302 |
\<body>\n\ |
|
14541 | 303 |
\<div class=\"head\">\ |
6405 | 304 |
\<h1>" ^ plain title ^ "</h1>\n" |
6324 | 305 |
|
14541 | 306 |
val end_document = "\n</div>\n</body>\n</html>\n"; |
6324 | 307 |
|
6754 | 308 |
fun gen_link how (path, name) = para (href_path path how ^ " to index of " ^ plain name); |
309 |
val up_link = gen_link "Up"; |
|
310 |
val back_link = gen_link "Back"; |
|
6338 | 311 |
|
312 |
||
313 |
(* session index *) |
|
314 |
||
7725 | 315 |
fun begin_index up (index_path, session) opt_readme opt_doc graph = |
6754 | 316 |
begin_document ("Index of " ^ session) ^ up_link up ^ |
317 |
para ("View " ^ href_path graph "theory dependencies" ^ |
|
7725 | 318 |
(case opt_readme of None => "" | Some p => "<br>\nView " ^ href_path p "README") ^ |
319 |
(case opt_doc of None => "" | Some p => "<br>\nView " ^ href_path p "document")) ^ |
|
14541 | 320 |
"\n</div>\n<hr>\n<div class=\"theories\">\n<h2>Theories</h2>\n<ul>\n"; |
6338 | 321 |
|
322 |
val end_index = end_document; |
|
323 |
||
6649 | 324 |
fun choice chs s = space_implode " " (map (fn (s', lnk) => |
325 |
enclose "[" "]" (if s = s' then keyword s' else href_name lnk s')) chs); |
|
326 |
||
9415 | 327 |
fun applet_pages session back = |
6649 | 328 |
let |
9415 | 329 |
val sizes = |
330 |
[("small", "small.html", ("500", "400")), |
|
331 |
("medium", "medium.html", ("650", "520")), |
|
332 |
("large", "large.html", ("800", "640"))]; |
|
6649 | 333 |
|
9415 | 334 |
fun applet_page (size, name, (width, height)) = |
6754 | 335 |
let |
336 |
val browser_size = "Set browser size: " ^ |
|
9415 | 337 |
choice (map (fn (y, z, _) => (y, z)) sizes) size; |
6754 | 338 |
in |
339 |
(name, begin_document ("Theory dependencies of " ^ session) ^ |
|
340 |
back_link back ^ |
|
9415 | 341 |
para browser_size ^ |
14541 | 342 |
"\n</div>\n<hr>\n<div class=\"graphbrowser\">\n<applet code=\"GraphBrowser/GraphBrowser.class\" \ |
343 |
\archive=\"GraphBrowser.jar\" \ |
|
9045 | 344 |
\width=" ^ width ^ " height=" ^ height ^ ">\n\ |
9415 | 345 |
\<param name=\"graphfile\" value=\"" ^ "session.graph" ^ "\">\n\ |
6754 | 346 |
\</applet>\n<hr>" ^ end_document) |
6649 | 347 |
end; |
9415 | 348 |
in map applet_page sizes end; |
6649 | 349 |
|
350 |
||
6405 | 351 |
fun entry (p, s) = "<li>" ^ href_path p (plain s) ^ "\n"; |
352 |
||
6338 | 353 |
val theory_entry = entry; |
354 |
||
6405 | 355 |
fun session_entries [] = "</ul>" |
356 |
| session_entries es = |
|
14541 | 357 |
"</ul>\n</div>\n<hr>\n<div class=\"sessions\">\n<h2>Sessions</h2>\n<ul>\n" ^ implode (map entry es) ^ "</ul>"; |
6324 | 358 |
|
359 |
||
360 |
(* theory *) |
|
361 |
||
14571 | 362 |
fun verbatim_source ss = |
363 |
"\n</div>\n<hr>\n<div class=\"source\">\n<pre>" ^ |
|
364 |
implode (output_symbols ss) ^ |
|
365 |
"</pre>\n</div>\n<hr>\n<div class=\"theorems\">\n"; |
|
6324 | 366 |
|
367 |
||
368 |
local |
|
7408 | 369 |
fun encl None = enclose "[" "]" |
370 |
| encl (Some false) = enclose "(" ")" |
|
371 |
| encl (Some true) = I; |
|
6324 | 372 |
|
7408 | 373 |
fun file (opt_ref, path, loadit) = href_opt_path opt_ref (encl loadit (file_path path)); |
7831 | 374 |
val files = space_implode " " o map file; |
6376 | 375 |
val parents = space_implode " + " o map (uncurry href_opt_path o apsnd name); |
6361 | 376 |
|
6376 | 377 |
fun theory up A = |
378 |
begin_document ("Theory " ^ A) ^ "\n" ^ up_link up ^ |
|
6324 | 379 |
keyword "theory" ^ " " ^ name A ^ " = "; |
380 |
in |
|
381 |
||
6376 | 382 |
fun begin_theory up A Bs [] body = theory up A ^ parents Bs ^ ":\n" ^ body |
12413 | 383 |
| begin_theory up A Bs Ps body = theory up A ^ parents Bs ^ "<br>\n" ^ keyword "files" ^ |
6376 | 384 |
" " ^ files Ps ^ ":" ^ "\n" ^ body; |
6324 | 385 |
end; |
386 |
||
6338 | 387 |
val end_theory = end_document; |
6324 | 388 |
|
389 |
||
390 |
(* ML file *) |
|
391 |
||
392 |
fun ml_file path str = |
|
6649 | 393 |
begin_document ("File " ^ Url.pack path) ^ |
14571 | 394 |
"\n</div>\n<hr><div class=\"mlsource\">\n" ^ |
395 |
verbatim str ^ |
|
396 |
"\n</div>\n<hr>\n<div class=\"mlfooter\">\n" ^ |
|
14541 | 397 |
end_document; |
6324 | 398 |
|
399 |
||
7408 | 400 |
(* theorems *) |
6324 | 401 |
|
7572 | 402 |
local |
403 |
||
7408 | 404 |
val string_of_thm = |
14839
c994f1c57fc7
handle raw symbols; Output.add_mode; more robust handling of sub/superscript;
wenzelm
parents:
14775
diff
changeset
|
405 |
Output.output o Pretty.setmp_margin 80 Pretty.string_of o |
6324 | 406 |
Display.pretty_thm_no_quote o #1 o Drule.freeze_thaw; |
407 |
||
408 |
fun thm th = preform (prefix_lines " " (html_mode string_of_thm th)); |
|
7408 | 409 |
|
7572 | 410 |
fun thm_name "" = "" |
411 |
| thm_name a = " " ^ name (a ^ ":"); |
|
412 |
||
413 |
in |
|
414 |
||
13531 | 415 |
fun result k (a, ths) = para (cat_lines ((keyword k ^ thm_name a) :: map thm ths)); |
7572 | 416 |
|
13531 | 417 |
fun results _ [] = "" |
418 |
| results k (res :: ress) = cat_lines (result k res :: map (result "and") ress); |
|
7572 | 419 |
|
420 |
end; |
|
6324 | 421 |
|
422 |
||
7634 | 423 |
(* sections *) |
6324 | 424 |
|
8088 | 425 |
fun chapter heading = "\n\n<h1>" ^ plain heading ^ "</h1>\n"; |
6324 | 426 |
fun section heading = "\n\n<h2>" ^ plain heading ^ "</h2>\n"; |
7634 | 427 |
fun subsection heading = "\n\n<h3>" ^ plain heading ^ "</h3>\n"; |
428 |
fun subsubsection heading = "\n\n<h4>" ^ plain heading ^ "</h4>\n"; |
|
6324 | 429 |
|
430 |
||
431 |
(** theory setup **) |
|
432 |
||
433 |
val setup = |
|
434 |
[Theory.add_mode_tokentrfuns htmlN html_trans]; |
|
435 |
||
436 |
||
437 |
end; |