author | wenzelm |
Sun, 06 Dec 2009 23:09:14 +0100 | |
changeset 34003 | 610e41138486 |
parent 33986 | 041dc6d8d344 |
child 37146 | f652333bbf8e |
permissions | -rw-r--r-- |
24584 | 1 |
(* Title: Pure/Thy/html.ML |
9415 | 2 |
Author: Markus Wenzel and Stefan Berghofer, TU Muenchen |
6324 | 3 |
|
9415 | 4 |
HTML presentation elements. |
6324 | 5 |
*) |
6 |
||
7 |
signature HTML = |
|
8 |
sig |
|
23724 | 9 |
val html_mode: ('a -> 'b) -> 'a -> 'b |
23622 | 10 |
type text = string |
6324 | 11 |
val plain: string -> text |
12 |
val name: string -> text |
|
13 |
val keyword: string -> text |
|
23622 | 14 |
val command: string -> text |
6324 | 15 |
val file_name: string -> text |
6649 | 16 |
val file_path: Url.T -> text |
6324 | 17 |
val href_name: string -> text -> text |
6649 | 18 |
val href_path: Url.T -> text -> text |
19 |
val href_opt_path: Url.T option -> text -> text |
|
6376 | 20 |
val para: text -> text |
6324 | 21 |
val preform: text -> text |
22 |
val verbatim: string -> text |
|
17470
6e9d910c3837
added with_charset: string -> ('a -> 'b) -> 'a -> 'b;
wenzelm
parents:
17412
diff
changeset
|
23 |
val with_charset: string -> ('a -> 'b) -> 'a -> 'b |
23724 | 24 |
val begin_document: string -> text |
25 |
val end_document: text |
|
17080 | 26 |
val begin_index: Url.T * string -> Url.T * string -> (Url.T * string) list -> Url.T -> text |
9415 | 27 |
val applet_pages: string -> Url.T * string -> (string * string) list |
6649 | 28 |
val theory_entry: Url.T * string -> text |
29 |
val session_entries: (Url.T * string) list -> text |
|
27861
911bf8e58c4c
removed obsolete verbatim_source, results, chapter, section etc.;
wenzelm
parents:
27832
diff
changeset
|
30 |
val theory_source: text -> text |
6649 | 31 |
val begin_theory: Url.T * string -> string -> (Url.T option * string) list -> |
27490 | 32 |
(Url.T * Url.T * bool) list -> text -> text |
6649 | 33 |
val ml_file: Url.T -> string -> text |
6324 | 34 |
end; |
35 |
||
36 |
structure HTML: HTML = |
|
37 |
struct |
|
38 |
||
39 |
||
40 |
(** HTML print modes **) |
|
41 |
||
42 |
(* mode *) |
|
43 |
||
44 |
val htmlN = "HTML"; |
|
23935 | 45 |
fun html_mode f x = PrintMode.with_modes [htmlN] f x; |
6324 | 46 |
|
47 |
||
33985 | 48 |
(* common markup *) |
49 |
||
50 |
fun span class = ("<span class=" ^ quote (XML.text class) ^ ">", "</span>"); |
|
51 |
||
52 |
val _ = Markup.add_mode htmlN (fn (name, _) => span name); |
|
53 |
||
54 |
||
6324 | 55 |
(* symbol output *) |
56 |
||
6338 | 57 |
local |
33985 | 58 |
val hidden = XML.text #> (span Markup.hiddenN |-> enclose); |
59 |
||
16196 | 60 |
val html_syms = Symtab.make |
34003
610e41138486
output_syms: permissive treatment of control symbols, cf. Scala version;
wenzelm
parents:
33986
diff
changeset
|
61 |
[("", (0, "")), |
610e41138486
output_syms: permissive treatment of control symbols, cf. Scala version;
wenzelm
parents:
33986
diff
changeset
|
62 |
("\n", (0, "<br/>")), |
33986
041dc6d8d344
output linefeed as </br> -- workaround problem with <pre> in Lobo Browser 0.98.4;
wenzelm
parents:
33985
diff
changeset
|
63 |
("'", (1, "'")), |
33983
cfbf1ff6170d
output "'" as "'" which is a bit more portable ("'" is defined in XML/XHTML, but not in old-style HTML4);
wenzelm
parents:
33222
diff
changeset
|
64 |
("\\<spacespace>", (2, " ")), |
23622 | 65 |
("\\<exclamdown>", (1, "¡")), |
66 |
("\\<cent>", (1, "¢")), |
|
67 |
("\\<pounds>", (1, "£")), |
|
68 |
("\\<currency>", (1, "¤")), |
|
69 |
("\\<yen>", (1, "¥")), |
|
70 |
("\\<bar>", (1, "¦")), |
|
71 |
("\\<section>", (1, "§")), |
|
72 |
("\\<dieresis>", (1, "¨")), |
|
73 |
("\\<copyright>", (1, "©")), |
|
74 |
("\\<ordfeminine>", (1, "ª")), |
|
75 |
("\\<guillemotleft>", (1, "«")), |
|
76 |
("\\<not>", (1, "¬")), |
|
77 |
("\\<hyphen>", (1, "­")), |
|
78 |
("\\<registered>", (1, "®")), |
|
79 |
("\\<inverse>", (1, "¯")), |
|
80 |
("\\<degree>", (1, "°")), |
|
81 |
("\\<plusminus>", (1, "±")), |
|
82 |
("\\<twosuperior>", (1, "²")), |
|
83 |
("\\<threesuperior>", (1, "³")), |
|
84 |
("\\<acute>", (1, "´")), |
|
85 |
("\\<paragraph>", (1, "¶")), |
|
86 |
("\\<cdot>", (1, "·")), |
|
87 |
("\\<cedilla>", (1, "¸")), |
|
88 |
("\\<onesuperior>", (1, "¹")), |
|
89 |
("\\<ordmasculine>", (1, "º")), |
|
90 |
("\\<guillemotright>", (1, "»")), |
|
91 |
("\\<onequarter>", (1, "¼")), |
|
92 |
("\\<onehalf>", (1, "½")), |
|
93 |
("\\<threequarters>", (1, "¾")), |
|
94 |
("\\<questiondown>", (1, "¿")), |
|
95 |
("\\<times>", (1, "×")), |
|
96 |
("\\<div>", (1, "÷")), |
|
97 |
("\\<circ>", (1, "o")), |
|
98 |
("\\<Alpha>", (1, "Α")), |
|
99 |
("\\<Beta>", (1, "Β")), |
|
100 |
("\\<Gamma>", (1, "Γ")), |
|
101 |
("\\<Delta>", (1, "Δ")), |
|
102 |
("\\<Epsilon>", (1, "Ε")), |
|
103 |
("\\<Zeta>", (1, "Ζ")), |
|
104 |
("\\<Eta>", (1, "Η")), |
|
105 |
("\\<Theta>", (1, "Θ")), |
|
106 |
("\\<Iota>", (1, "Ι")), |
|
107 |
("\\<Kappa>", (1, "Κ")), |
|
108 |
("\\<Lambda>", (1, "Λ")), |
|
109 |
("\\<Mu>", (1, "Μ")), |
|
110 |
("\\<Nu>", (1, "Ν")), |
|
111 |
("\\<Xi>", (1, "Ξ")), |
|
112 |
("\\<Omicron>", (1, "Ο")), |
|
113 |
("\\<Pi>", (1, "Π")), |
|
114 |
("\\<Rho>", (1, "Ρ")), |
|
115 |
("\\<Sigma>", (1, "Σ")), |
|
116 |
("\\<Tau>", (1, "Τ")), |
|
117 |
("\\<Upsilon>", (1, "Υ")), |
|
118 |
("\\<Phi>", (1, "Φ")), |
|
119 |
("\\<Chi>", (1, "Χ")), |
|
120 |
("\\<Psi>", (1, "Ψ")), |
|
121 |
("\\<Omega>", (1, "Ω")), |
|
122 |
("\\<alpha>", (1, "α")), |
|
123 |
("\\<beta>", (1, "β")), |
|
124 |
("\\<gamma>", (1, "γ")), |
|
125 |
("\\<delta>", (1, "δ")), |
|
126 |
("\\<epsilon>", (1, "ε")), |
|
127 |
("\\<zeta>", (1, "ζ")), |
|
128 |
("\\<eta>", (1, "η")), |
|
129 |
("\\<theta>", (1, "ϑ")), |
|
130 |
("\\<iota>", (1, "ι")), |
|
131 |
("\\<kappa>", (1, "κ")), |
|
132 |
("\\<lambda>", (1, "λ")), |
|
133 |
("\\<mu>", (1, "μ")), |
|
134 |
("\\<nu>", (1, "ν")), |
|
135 |
("\\<xi>", (1, "ξ")), |
|
136 |
("\\<omicron>", (1, "ο")), |
|
137 |
("\\<pi>", (1, "π")), |
|
138 |
("\\<rho>", (1, "ρ")), |
|
139 |
("\\<sigma>", (1, "σ")), |
|
140 |
("\\<tau>", (1, "τ")), |
|
141 |
("\\<upsilon>", (1, "υ")), |
|
142 |
("\\<phi>", (1, "φ")), |
|
143 |
("\\<chi>", (1, "χ")), |
|
144 |
("\\<psi>", (1, "ψ")), |
|
145 |
("\\<omega>", (1, "ω")), |
|
146 |
("\\<bullet>", (1, "•")), |
|
147 |
("\\<dots>", (1, "…")), |
|
148 |
("\\<Re>", (1, "ℜ")), |
|
149 |
("\\<Im>", (1, "ℑ")), |
|
150 |
("\\<wp>", (1, "℘")), |
|
151 |
("\\<forall>", (1, "∀")), |
|
152 |
("\\<partial>", (1, "∂")), |
|
153 |
("\\<exists>", (1, "∃")), |
|
154 |
("\\<emptyset>", (1, "∅")), |
|
155 |
("\\<nabla>", (1, "∇")), |
|
156 |
("\\<in>", (1, "∈")), |
|
157 |
("\\<notin>", (1, "∉")), |
|
158 |
("\\<Prod>", (1, "∏")), |
|
159 |
("\\<Sum>", (1, "∑")), |
|
160 |
("\\<star>", (1, "∗")), |
|
161 |
("\\<propto>", (1, "∝")), |
|
162 |
("\\<infinity>", (1, "∞")), |
|
163 |
("\\<angle>", (1, "∠")), |
|
164 |
("\\<and>", (1, "∧")), |
|
165 |
("\\<or>", (1, "∨")), |
|
166 |
("\\<inter>", (1, "∩")), |
|
167 |
("\\<union>", (1, "∪")), |
|
168 |
("\\<sim>", (1, "∼")), |
|
169 |
("\\<cong>", (1, "≅")), |
|
170 |
("\\<approx>", (1, "≈")), |
|
171 |
("\\<noteq>", (1, "≠")), |
|
172 |
("\\<equiv>", (1, "≡")), |
|
173 |
("\\<le>", (1, "≤")), |
|
174 |
("\\<ge>", (1, "≥")), |
|
175 |
("\\<subset>", (1, "⊂")), |
|
176 |
("\\<supset>", (1, "⊃")), |
|
177 |
("\\<subseteq>", (1, "⊆")), |
|
178 |
("\\<supseteq>", (1, "⊇")), |
|
179 |
("\\<oplus>", (1, "⊕")), |
|
180 |
("\\<otimes>", (1, "⊗")), |
|
181 |
("\\<bottom>", (1, "⊥")), |
|
182 |
("\\<lceil>", (1, "⌈")), |
|
183 |
("\\<rceil>", (1, "⌉")), |
|
184 |
("\\<lfloor>", (1, "⌊")), |
|
185 |
("\\<rfloor>", (1, "⌋")), |
|
186 |
("\\<langle>", (1, "⟨")), |
|
187 |
("\\<rangle>", (1, "⟩")), |
|
188 |
("\\<lozenge>", (1, "◊")), |
|
189 |
("\\<spadesuit>", (1, "♠")), |
|
190 |
("\\<clubsuit>", (1, "♣")), |
|
191 |
("\\<heartsuit>", (1, "♥")), |
|
192 |
("\\<diamondsuit>", (1, "♦")), |
|
193 |
("\\<lbrakk>", (2, "[|")), |
|
194 |
("\\<rbrakk>", (2, "|]")), |
|
195 |
("\\<Longrightarrow>", (3, "==>")), |
|
196 |
("\\<Rightarrow>", (2, "=>")), |
|
197 |
("\\<And>", (2, "!!")), |
|
198 |
("\\<Colon>", (2, "::")), |
|
199 |
("\\<lparr>", (2, "(|")), |
|
200 |
("\\<rparr>", (2, "|)),")), |
|
201 |
("\\<longleftrightarrow>", (3, "<->")), |
|
202 |
("\\<longrightarrow>", (3, "-->")), |
|
203 |
("\\<rightarrow>", (2, "->")), |
|
33985 | 204 |
("\\<^bsub>", (0, hidden "\\<^bsub>" ^ "<sub>")), |
205 |
("\\<^esub>", (0, hidden "\\<^esub>" ^ "</sub>")), |
|
206 |
("\\<^bsup>", (0, hidden "\\<^bsup>" ^ "<sup>")), |
|
207 |
("\\<^esup>", (0, hidden "\\<^esup>" ^ "</sup>"))]; |
|
17178 | 208 |
|
16196 | 209 |
fun output_sym s = |
23622 | 210 |
if Symbol.is_raw s then (1, Symbol.decode_raw s) |
20742 | 211 |
else |
33983
cfbf1ff6170d
output "'" as "'" which is a bit more portable ("'" is defined in XML/XHTML, but not in old-style HTML4);
wenzelm
parents:
33222
diff
changeset
|
212 |
(case Symtab.lookup html_syms s of |
cfbf1ff6170d
output "'" as "'" which is a bit more portable ("'" is defined in XML/XHTML, but not in old-style HTML4);
wenzelm
parents:
33222
diff
changeset
|
213 |
SOME x => x |
26709 | 214 |
| NONE => (size s, XML.text s)); |
6324 | 215 |
|
33985 | 216 |
fun output_markup (bg, en) s1 s2 = |
217 |
let val (n, txt) = output_sym s2 |
|
218 |
in (n, hidden s1 ^ enclose bg en txt) end; |
|
14534 | 219 |
|
33985 | 220 |
val output_sub = output_markup ("<sub>", "</sub>"); |
221 |
val output_sup = output_markup ("<sup>", "</sup>"); |
|
222 |
val output_bold = output_markup (span "bold"); |
|
223 |
val output_loc = output_markup (span "loc"); |
|
224 |
||
34003
610e41138486
output_syms: permissive treatment of control symbols, cf. Scala version;
wenzelm
parents:
33986
diff
changeset
|
225 |
fun output_syms (s1 :: rest) = |
610e41138486
output_syms: permissive treatment of control symbols, cf. Scala version;
wenzelm
parents:
33986
diff
changeset
|
226 |
let val (s2, ss) = (case rest of [] => ("", []) | s2 :: ss => (s2, ss)) in |
610e41138486
output_syms: permissive treatment of control symbols, cf. Scala version;
wenzelm
parents:
33986
diff
changeset
|
227 |
if s1 = "\\<^sub>" orelse s1 = "\\<^isub>" then output_sub s1 s2 :: output_syms ss |
610e41138486
output_syms: permissive treatment of control symbols, cf. Scala version;
wenzelm
parents:
33986
diff
changeset
|
228 |
else if s1 = "\\<^sup>" orelse s1 = "\\<^isup>" then output_sup s1 s2 :: output_syms ss |
610e41138486
output_syms: permissive treatment of control symbols, cf. Scala version;
wenzelm
parents:
33986
diff
changeset
|
229 |
else if s1 = "\\<^bold>" then output_bold s1 s2 :: output_syms ss |
610e41138486
output_syms: permissive treatment of control symbols, cf. Scala version;
wenzelm
parents:
33986
diff
changeset
|
230 |
else if s1 = "\\<^loc>" then output_loc s1 s2 :: output_syms ss |
610e41138486
output_syms: permissive treatment of control symbols, cf. Scala version;
wenzelm
parents:
33986
diff
changeset
|
231 |
else output_sym s1 :: output_syms rest |
610e41138486
output_syms: permissive treatment of control symbols, cf. Scala version;
wenzelm
parents:
33986
diff
changeset
|
232 |
end |
17178 | 233 |
| output_syms [] = []; |
6338 | 234 |
in |
6324 | 235 |
|
6338 | 236 |
fun output_width str = |
33986
041dc6d8d344
output linefeed as </br> -- workaround problem with <pre> in Lobo Browser 0.98.4;
wenzelm
parents:
33985
diff
changeset
|
237 |
let val (syms, width) = |
041dc6d8d344
output linefeed as </br> -- workaround problem with <pre> in Lobo Browser 0.98.4;
wenzelm
parents:
33985
diff
changeset
|
238 |
fold_map (fn (w, s) => fn width => (s, w + width)) (output_syms (Symbol.explode str)) 0 |
041dc6d8d344
output linefeed as </br> -- workaround problem with <pre> in Lobo Browser 0.98.4;
wenzelm
parents:
33985
diff
changeset
|
239 |
in (implode syms, width) end; |
6338 | 240 |
|
241 |
val output = #1 o output_width; |
|
242 |
||
26709 | 243 |
val _ = Output.add_mode htmlN output_width Symbol.encode_raw; |
244 |
||
6338 | 245 |
end; |
246 |
||
6324 | 247 |
|
248 |
||
249 |
(** HTML markup **) |
|
250 |
||
251 |
type text = string; |
|
252 |
||
253 |
||
254 |
(* atoms *) |
|
255 |
||
256 |
val plain = output; |
|
19265 | 257 |
val name = enclose "<span class=\"name\">" "</span>" o output; |
258 |
val keyword = enclose "<span class=\"keyword\">" "</span>" o output; |
|
23622 | 259 |
val command = enclose "<span class=\"command\">" "</span>" o output; |
19265 | 260 |
val file_name = enclose "<span class=\"filename\">" "</span>" o output; |
21858
05f57309170c
avoid conflict with Alice keywords: renamed pack -> implode, unpack -> explode, any -> many, avoided assert;
wenzelm
parents:
20742
diff
changeset
|
261 |
val file_path = file_name o Url.implode; |
6324 | 262 |
|
263 |
||
264 |
(* misc *) |
|
265 |
||
28840 | 266 |
fun href_name s txt = "<a href=" ^ quote s ^ ">" ^ txt ^ "</a>"; |
21858
05f57309170c
avoid conflict with Alice keywords: renamed pack -> implode, unpack -> explode, any -> many, avoided assert;
wenzelm
parents:
20742
diff
changeset
|
267 |
fun href_path path txt = href_name (Url.implode path) txt; |
6376 | 268 |
|
15531 | 269 |
fun href_opt_path NONE txt = txt |
270 |
| href_opt_path (SOME p) txt = href_path p txt; |
|
6376 | 271 |
|
12413 | 272 |
fun para txt = "\n<p>" ^ txt ^ "</p>\n"; |
27830 | 273 |
fun preform txt = "<pre>" ^ txt ^ "</pre>"; |
6324 | 274 |
val verbatim = preform o output; |
275 |
||
276 |
||
277 |
(* document *) |
|
278 |
||
32738 | 279 |
val charset = Unsynchronized.ref "ISO-8859-1"; |
33222 | 280 |
fun with_charset s = setmp_noncritical charset s; (* FIXME unreliable *) |
17470
6e9d910c3837
added with_charset: string -> ('a -> 'b) -> 'a -> 'b;
wenzelm
parents:
17412
diff
changeset
|
281 |
|
6324 | 282 |
fun begin_document title = |
27829 | 283 |
let val cs = ! charset in |
284 |
"<?xml version=\"1.0\" encoding=\"" ^ cs ^ "\" ?>\n\ |
|
27896 | 285 |
\<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \ |
27829 | 286 |
\\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n\ |
287 |
\<html xmlns=\"http://www.w3.org/1999/xhtml\">\n\ |
|
288 |
\<head>\n\ |
|
289 |
\<meta http-equiv=\"Content-Type\" content=\"text/html; charset=" ^ cs ^ "\"/>\n\ |
|
290 |
\<title>" ^ plain (title ^ " (" ^ Distribution.version ^ ")") ^ "</title>\n\ |
|
291 |
\<link media=\"all\" rel=\"stylesheet\" type=\"text/css\" href=\"isabelle.css\"/>\n\ |
|
292 |
\</head>\n\ |
|
293 |
\\n\ |
|
294 |
\<body>\n\ |
|
295 |
\<div class=\"head\">\ |
|
296 |
\<h1>" ^ plain title ^ "</h1>\n" |
|
297 |
end; |
|
6324 | 298 |
|
14541 | 299 |
val end_document = "\n</div>\n</body>\n</html>\n"; |
6324 | 300 |
|
6754 | 301 |
fun gen_link how (path, name) = para (href_path path how ^ " to index of " ^ plain name); |
302 |
val up_link = gen_link "Up"; |
|
303 |
val back_link = gen_link "Back"; |
|
6338 | 304 |
|
305 |
||
306 |
(* session index *) |
|
307 |
||
17080 | 308 |
fun begin_index up (index_path, session) docs graph = |
6754 | 309 |
begin_document ("Index of " ^ session) ^ up_link up ^ |
310 |
para ("View " ^ href_path graph "theory dependencies" ^ |
|
27829 | 311 |
implode (map (fn (p, name) => "<br/>\nView " ^ href_path p name) docs)) ^ |
312 |
"\n</div>\n<hr/>\n<div class=\"theories\">\n<h2>Theories</h2>\n<ul>\n"; |
|
6338 | 313 |
|
6649 | 314 |
fun choice chs s = space_implode " " (map (fn (s', lnk) => |
315 |
enclose "[" "]" (if s = s' then keyword s' else href_name lnk s')) chs); |
|
316 |
||
9415 | 317 |
fun applet_pages session back = |
6649 | 318 |
let |
9415 | 319 |
val sizes = |
320 |
[("small", "small.html", ("500", "400")), |
|
321 |
("medium", "medium.html", ("650", "520")), |
|
322 |
("large", "large.html", ("800", "640"))]; |
|
6649 | 323 |
|
9415 | 324 |
fun applet_page (size, name, (width, height)) = |
6754 | 325 |
let |
326 |
val browser_size = "Set browser size: " ^ |
|
9415 | 327 |
choice (map (fn (y, z, _) => (y, z)) sizes) size; |
6754 | 328 |
in |
329 |
(name, begin_document ("Theory dependencies of " ^ session) ^ |
|
330 |
back_link back ^ |
|
9415 | 331 |
para browser_size ^ |
27829 | 332 |
"\n</div>\n<hr/>\n<div class=\"graphbrowser\">\n\ |
17080 | 333 |
\<applet code=\"GraphBrowser/GraphBrowser.class\" \ |
14541 | 334 |
\archive=\"GraphBrowser.jar\" \ |
27832
992c6d984925
<applet>: more XHTML 1.0 Transitional conformance;
wenzelm
parents:
27830
diff
changeset
|
335 |
\width=" ^ quote width ^ " height=" ^ quote height ^ ">\n\ |
992c6d984925
<applet>: more XHTML 1.0 Transitional conformance;
wenzelm
parents:
27830
diff
changeset
|
336 |
\<param name=\"graphfile\" value=\"" ^ "session.graph" ^ "\"/>\n\ |
27829 | 337 |
\</applet>\n<hr/>" ^ end_document) |
6649 | 338 |
end; |
9415 | 339 |
in map applet_page sizes end; |
6649 | 340 |
|
341 |
||
27829 | 342 |
fun entry (p, s) = "<li>" ^ href_path p (plain s) ^ "</li>\n"; |
6405 | 343 |
|
6338 | 344 |
val theory_entry = entry; |
345 |
||
6405 | 346 |
fun session_entries [] = "</ul>" |
347 |
| session_entries es = |
|
27829 | 348 |
"</ul>\n</div>\n<hr/>\n<div class=\"sessions\">\n\ |
17080 | 349 |
\<h2>Sessions</h2>\n<ul>\n" ^ implode (map entry es) ^ "</ul>"; |
6324 | 350 |
|
351 |
||
352 |
(* theory *) |
|
353 |
||
27861
911bf8e58c4c
removed obsolete verbatim_source, results, chapter, section etc.;
wenzelm
parents:
27832
diff
changeset
|
354 |
val theory_source = enclose |
911bf8e58c4c
removed obsolete verbatim_source, results, chapter, section etc.;
wenzelm
parents:
27832
diff
changeset
|
355 |
"\n</div>\n<hr/>\n<div class=\"source\">\n<pre>" |
911bf8e58c4c
removed obsolete verbatim_source, results, chapter, section etc.;
wenzelm
parents:
27832
diff
changeset
|
356 |
"</pre>\n<hr/>\n"; |
6324 | 357 |
|
358 |
||
359 |
local |
|
27490 | 360 |
fun file (href, path, loadit) = |
361 |
href_path href (if loadit then file_path path else enclose "(" ")" (file_path path)); |
|
6361 | 362 |
|
6376 | 363 |
fun theory up A = |
364 |
begin_document ("Theory " ^ A) ^ "\n" ^ up_link up ^ |
|
23622 | 365 |
command "theory" ^ " " ^ name A; |
16267
0773b17922d8
present new-style theory header, with 'imports' and 'uses';
wenzelm
parents:
16196
diff
changeset
|
366 |
|
0773b17922d8
present new-style theory header, with 'imports' and 'uses';
wenzelm
parents:
16196
diff
changeset
|
367 |
fun imports Bs = |
0773b17922d8
present new-style theory header, with 'imports' and 'uses';
wenzelm
parents:
16196
diff
changeset
|
368 |
keyword "imports" ^ " " ^ space_implode " " (map (uncurry href_opt_path o apsnd name) Bs); |
0773b17922d8
present new-style theory header, with 'imports' and 'uses';
wenzelm
parents:
16196
diff
changeset
|
369 |
|
27829 | 370 |
fun uses Ps = keyword "uses" ^ " " ^ space_implode " " (map file Ps) ^ "<br/>\n"; |
6324 | 371 |
in |
372 |
||
16267
0773b17922d8
present new-style theory header, with 'imports' and 'uses';
wenzelm
parents:
16196
diff
changeset
|
373 |
fun begin_theory up A Bs Ps body = |
27829 | 374 |
theory up A ^ "<br/>\n" ^ |
375 |
imports Bs ^ "<br/>\n" ^ |
|
16267
0773b17922d8
present new-style theory header, with 'imports' and 'uses';
wenzelm
parents:
16196
diff
changeset
|
376 |
(if null Ps then "" else uses Ps) ^ |
0773b17922d8
present new-style theory header, with 'imports' and 'uses';
wenzelm
parents:
16196
diff
changeset
|
377 |
body; |
0773b17922d8
present new-style theory header, with 'imports' and 'uses';
wenzelm
parents:
16196
diff
changeset
|
378 |
|
6324 | 379 |
end; |
380 |
||
381 |
||
382 |
(* ML file *) |
|
383 |
||
384 |
fun ml_file path str = |
|
21858
05f57309170c
avoid conflict with Alice keywords: renamed pack -> implode, unpack -> explode, any -> many, avoided assert;
wenzelm
parents:
20742
diff
changeset
|
385 |
begin_document ("File " ^ Url.implode path) ^ |
27829 | 386 |
"\n</div>\n<hr/><div class=\"mlsource\">\n" ^ |
14571 | 387 |
verbatim str ^ |
27861
911bf8e58c4c
removed obsolete verbatim_source, results, chapter, section etc.;
wenzelm
parents:
27832
diff
changeset
|
388 |
"\n</div>\n<hr/>\n<div class=\"mlfooter\">" ^ |
14541 | 389 |
end_document; |
6324 | 390 |
|
7572 | 391 |
end; |