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