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