src/Pure/Thy/html.ML
author wenzelm
Tue, 01 Jun 1999 18:01:01 +0200
changeset 6754 c23c542a32e5
parent 6649 2156012be986
child 7408 1ec1567c1307
permissions -rw-r--r--
tuned markup;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
     1
(*  Title:      Pure/Thy/HTML.ML
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
     2
    ID:         $Id$
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
     3
    Author:     Markus Wenzel, TU Muenchen
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
     4
6338
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
     5
HTML presentation primitives.
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
     6
*)
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
     7
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
     8
signature HTML =
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
     9
sig
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    10
  val output: string -> string
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    11
  val output_width: string -> string * real
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    12
  type text (* = string *)
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    13
  val plain: string -> text
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    14
  val name: string -> text
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    15
  val keyword: string -> text
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    16
  val file_name: string -> text
6649
2156012be986 Reimplemented graph generator.
berghofe
parents: 6405
diff changeset
    17
  val file_path: Url.T -> text
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    18
  val href_name: string -> text -> text
6649
2156012be986 Reimplemented graph generator.
berghofe
parents: 6405
diff changeset
    19
  val href_path: Url.T -> text -> text
6376
wenzelm
parents: 6361
diff changeset
    20
  val href_opt_name: string option -> text -> text
6649
2156012be986 Reimplemented graph generator.
berghofe
parents: 6405
diff changeset
    21
  val href_opt_path: Url.T option -> text -> text
6376
wenzelm
parents: 6361
diff changeset
    22
  val para: text -> text
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    23
  val preform: text -> text
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    24
  val verbatim: string -> text
6649
2156012be986 Reimplemented graph generator.
berghofe
parents: 6405
diff changeset
    25
  val begin_index: Url.T * string -> Url.T * string -> Url.T option -> Url.T -> text
6338
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
    26
  val end_index: text
6649
2156012be986 Reimplemented graph generator.
berghofe
parents: 6405
diff changeset
    27
  val applet_pages: string -> Url.T -> Url.T * string -> bool -> (string * string) list
2156012be986 Reimplemented graph generator.
berghofe
parents: 6405
diff changeset
    28
  val theory_entry: Url.T * string -> text
2156012be986 Reimplemented graph generator.
berghofe
parents: 6405
diff changeset
    29
  val session_entries: (Url.T * string) list -> text
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    30
  val source: (string, 'a) Source.source -> text
6649
2156012be986 Reimplemented graph generator.
berghofe
parents: 6405
diff changeset
    31
  val begin_theory: Url.T * string -> string -> (Url.T option * string) list ->
2156012be986 Reimplemented graph generator.
berghofe
parents: 6405
diff changeset
    32
    (Url.T option * Url.T * bool) list -> text -> text
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    33
  val end_theory: text
6649
2156012be986 Reimplemented graph generator.
berghofe
parents: 6405
diff changeset
    34
  val ml_file: Url.T -> string -> text
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    35
  val theorem: string -> thm -> text
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    36
  val section: string -> text
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    37
  val setup: (theory -> theory) list
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    38
end;
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    39
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    40
structure HTML: HTML =
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    41
struct
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    42
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    43
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    44
(** HTML print modes **)
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    45
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    46
(* mode *)
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    47
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    48
val htmlN = "HTML";
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    49
fun html_mode f x = setmp print_mode [htmlN] f x;
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    50
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    51
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    52
(* symbol output *)
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    53
6338
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
    54
local
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
    55
  val escape = fn "<" => "&lt;" | ">" => "&gt;" | "&" => "&amp;" | c => c;
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    56
6338
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
    57
  val output_sym =
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
    58
    fn "\\<not>" => (1.0, "&not;")
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
    59
     | "\\<hyphen>" => (1.0, "&shy;")
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
    60
     | "\\<cdot>" => (1.0, "&middot;")
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
    61
     | "\\<times>" => (1.0, "&times;")
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
    62
     | "\\<copyright>" => (1.0, "&copy;")
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
    63
     | "\\<mu>" => (1.0, "&micro;")
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
    64
     | s => (real (size s), implode (map escape (explode s)));
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    65
6338
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
    66
  fun add_sym (width, (w: real, s)) = (width + w, s);
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
    67
in
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    68
6338
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
    69
fun output_width str =
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
    70
  if not (exists_string (equal "<" orf equal ">" orf equal "&") str) then (str, real (size str))
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
    71
  else
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
    72
    let val (width, syms) = foldl_map add_sym (0.0, map output_sym (Symbol.explode str))
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
    73
    in (implode syms, width) end;
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
    74
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
    75
val output = #1 o output_width;
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
    76
val output_symbols = map (#2 o output_sym);
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
    77
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
    78
end;
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
    79
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    80
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    81
val _ = Symbol.add_mode htmlN output_width;
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    82
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    83
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    84
(* token translations *)
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    85
6347
wenzelm
parents: 6338
diff changeset
    86
fun color col =
wenzelm
parents: 6338
diff changeset
    87
  apfst (enclose ("<font color=" ^ quote col ^ ">") "</font>") o output_width;
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    88
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    89
val html_trans =
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    90
 [("class", color "red"),
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    91
  ("tfree", color "purple"),
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    92
  ("tvar",  color "purple"),
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    93
  ("free",  color "blue"),
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    94
  ("bound", color "green"),
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    95
  ("var",   color "blue"),
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    96
  ("xnum",  color "yellow"),
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    97
  ("xstr",  color "brown")];
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    98
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    99
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   100
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   101
(** HTML markup **)
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   102
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   103
type text = string;
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   104
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   105
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   106
(* atoms *)
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   107
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   108
val plain = output;
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   109
fun name s = "<i>" ^ output s ^ "</i>";
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   110
fun keyword s = "<b>" ^ output s ^ "</b>";
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   111
fun file_name s = "<tt>" ^ output s ^ "</tt>";
6649
2156012be986 Reimplemented graph generator.
berghofe
parents: 6405
diff changeset
   112
val file_path = file_name o Url.pack;
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   113
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   114
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   115
(* misc *)
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   116
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   117
fun href_name s txt = "<a href=" ^ quote s ^ ">" ^ txt ^ "</a>";
6649
2156012be986 Reimplemented graph generator.
berghofe
parents: 6405
diff changeset
   118
fun href_path path txt = href_name (Url.pack path) txt;
6376
wenzelm
parents: 6361
diff changeset
   119
wenzelm
parents: 6361
diff changeset
   120
fun href_opt_name None txt = txt
wenzelm
parents: 6361
diff changeset
   121
  | href_opt_name (Some s) txt = href_name s txt;
wenzelm
parents: 6361
diff changeset
   122
wenzelm
parents: 6361
diff changeset
   123
fun href_opt_path None txt = txt
wenzelm
parents: 6361
diff changeset
   124
  | href_opt_path (Some p) txt = href_path p txt;
wenzelm
parents: 6361
diff changeset
   125
wenzelm
parents: 6361
diff changeset
   126
fun para txt = "\n<p>\n" ^ txt ^ "\n</p>\n";
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   127
fun preform txt = "<pre>" ^ txt ^ "</pre>";
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   128
val verbatim = preform o output;
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   129
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   130
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   131
(* document *)
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   132
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   133
fun begin_document title =
6405
wenzelm
parents: 6376
diff changeset
   134
  "<html>\n\
wenzelm
parents: 6376
diff changeset
   135
  \<head>\n\
wenzelm
parents: 6376
diff changeset
   136
  \<title>" ^ plain (title ^ " (" ^ version ^ ")") ^ "</title>\n\
wenzelm
parents: 6376
diff changeset
   137
  \</head>\n\
wenzelm
parents: 6376
diff changeset
   138
  \\n\
wenzelm
parents: 6376
diff changeset
   139
  \<body>\n\
wenzelm
parents: 6376
diff changeset
   140
  \<h1>" ^ plain title ^ "</h1>\n"
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   141
6405
wenzelm
parents: 6376
diff changeset
   142
val end_document = "\n</body>\n</html>\n";
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   143
6754
c23c542a32e5 tuned markup;
wenzelm
parents: 6649
diff changeset
   144
fun gen_link how (path, name) = para (href_path path how ^ " to index of " ^ plain name);
c23c542a32e5 tuned markup;
wenzelm
parents: 6649
diff changeset
   145
val up_link = gen_link "Up";
c23c542a32e5 tuned markup;
wenzelm
parents: 6649
diff changeset
   146
val back_link = gen_link "Back";
6338
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
   147
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
   148
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
   149
(* session index *)
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
   150
6649
2156012be986 Reimplemented graph generator.
berghofe
parents: 6405
diff changeset
   151
fun begin_index up (index_path, session) opt_readme graph =
6754
c23c542a32e5 tuned markup;
wenzelm
parents: 6649
diff changeset
   152
  begin_document ("Index of " ^ session) ^ up_link up ^
c23c542a32e5 tuned markup;
wenzelm
parents: 6649
diff changeset
   153
  para ("View " ^ href_path graph "theory dependencies" ^
c23c542a32e5 tuned markup;
wenzelm
parents: 6649
diff changeset
   154
    (case opt_readme of None => "" | Some p => "<br>\nView " ^ href_path p "README")) ^
6405
wenzelm
parents: 6376
diff changeset
   155
  "\n<hr>\n\n<h2>Theories</h2>\n<ul>\n";
6338
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
   156
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
   157
val end_index = end_document;
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
   158
6649
2156012be986 Reimplemented graph generator.
berghofe
parents: 6405
diff changeset
   159
fun choice chs s = space_implode " " (map (fn (s', lnk) =>
2156012be986 Reimplemented graph generator.
berghofe
parents: 6405
diff changeset
   160
  enclose "[" "]" (if s = s' then keyword s' else href_name lnk s')) chs);
2156012be986 Reimplemented graph generator.
berghofe
parents: 6405
diff changeset
   161
6754
c23c542a32e5 tuned markup;
wenzelm
parents: 6649
diff changeset
   162
fun applet_pages session codebase back alt_graph =
6649
2156012be986 Reimplemented graph generator.
berghofe
parents: 6405
diff changeset
   163
  let
2156012be986 Reimplemented graph generator.
berghofe
parents: 6405
diff changeset
   164
    val choices = [("none", "small",  "small.html"),
2156012be986 Reimplemented graph generator.
berghofe
parents: 6405
diff changeset
   165
                   ("none", "medium", "medium.html"),
2156012be986 Reimplemented graph generator.
berghofe
parents: 6405
diff changeset
   166
                   ("none", "large",  "large.html"),
2156012be986 Reimplemented graph generator.
berghofe
parents: 6405
diff changeset
   167
                   ("all",  "small",  "small_all.html"),
2156012be986 Reimplemented graph generator.
berghofe
parents: 6405
diff changeset
   168
                   ("all",  "medium", "medium_all.html"),
2156012be986 Reimplemented graph generator.
berghofe
parents: 6405
diff changeset
   169
                   ("all",  "large",  "large_all.html")];
2156012be986 Reimplemented graph generator.
berghofe
parents: 6405
diff changeset
   170
2156012be986 Reimplemented graph generator.
berghofe
parents: 6405
diff changeset
   171
    val sizes = [("small",  ("500", "400")),
2156012be986 Reimplemented graph generator.
berghofe
parents: 6405
diff changeset
   172
                 ("medium", ("650", "520")),
2156012be986 Reimplemented graph generator.
berghofe
parents: 6405
diff changeset
   173
                 ("large",  ("800", "640"))];
2156012be986 Reimplemented graph generator.
berghofe
parents: 6405
diff changeset
   174
2156012be986 Reimplemented graph generator.
berghofe
parents: 6405
diff changeset
   175
    fun applet_page (gtype, size, name) =
6754
c23c542a32e5 tuned markup;
wenzelm
parents: 6649
diff changeset
   176
      let
c23c542a32e5 tuned markup;
wenzelm
parents: 6649
diff changeset
   177
        val (width, height) = the (assoc (sizes, size));
c23c542a32e5 tuned markup;
wenzelm
parents: 6649
diff changeset
   178
        val subsessions =
c23c542a32e5 tuned markup;
wenzelm
parents: 6649
diff changeset
   179
          if alt_graph then
c23c542a32e5 tuned markup;
wenzelm
parents: 6649
diff changeset
   180
            "View subsessions: " ^ choice (map (fn (x, _, z) => (x, z))
c23c542a32e5 tuned markup;
wenzelm
parents: 6649
diff changeset
   181
              (filter (fn (_, y, _) => y = size) choices)) gtype ^ "<br>\n"
c23c542a32e5 tuned markup;
wenzelm
parents: 6649
diff changeset
   182
          else "";
c23c542a32e5 tuned markup;
wenzelm
parents: 6649
diff changeset
   183
        val browser_size = "Set browser size: " ^
c23c542a32e5 tuned markup;
wenzelm
parents: 6649
diff changeset
   184
          choice (map (fn (_, y, z) => (y, z)) (filter (fn (x, _, _) => x = gtype) choices)) size;
c23c542a32e5 tuned markup;
wenzelm
parents: 6649
diff changeset
   185
      in
c23c542a32e5 tuned markup;
wenzelm
parents: 6649
diff changeset
   186
        (name, begin_document ("Theory dependencies of " ^ session) ^
c23c542a32e5 tuned markup;
wenzelm
parents: 6649
diff changeset
   187
          back_link back ^
c23c542a32e5 tuned markup;
wenzelm
parents: 6649
diff changeset
   188
          para (subsessions ^ browser_size) ^
c23c542a32e5 tuned markup;
wenzelm
parents: 6649
diff changeset
   189
          "\n<hr>\n<applet code=\"GraphBrowser/GraphBrowser.class\" \
c23c542a32e5 tuned markup;
wenzelm
parents: 6649
diff changeset
   190
          \codebase=\"" ^ Url.pack codebase ^ "\" width=" ^ width ^ " height=" ^ height ^ ">\n\
c23c542a32e5 tuned markup;
wenzelm
parents: 6649
diff changeset
   191
          \<param name=\"graphfile\" value=\"" ^
c23c542a32e5 tuned markup;
wenzelm
parents: 6649
diff changeset
   192
          (if gtype = "all" then "all_sessions.graph" else "session.graph") ^ "\">\n\
c23c542a32e5 tuned markup;
wenzelm
parents: 6649
diff changeset
   193
          \</applet>\n<hr>" ^ end_document)
6649
2156012be986 Reimplemented graph generator.
berghofe
parents: 6405
diff changeset
   194
      end;
6754
c23c542a32e5 tuned markup;
wenzelm
parents: 6649
diff changeset
   195
  in map applet_page (take (if alt_graph then 6 else 3, choices)) end;
6649
2156012be986 Reimplemented graph generator.
berghofe
parents: 6405
diff changeset
   196
2156012be986 Reimplemented graph generator.
berghofe
parents: 6405
diff changeset
   197
6405
wenzelm
parents: 6376
diff changeset
   198
fun entry (p, s) = "<li>" ^ href_path p (plain s) ^ "\n";
wenzelm
parents: 6376
diff changeset
   199
6338
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
   200
val theory_entry = entry;
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
   201
6405
wenzelm
parents: 6376
diff changeset
   202
fun session_entries [] = "</ul>"
wenzelm
parents: 6376
diff changeset
   203
  | session_entries es =
wenzelm
parents: 6376
diff changeset
   204
      "</ul>\n<hr>\n\n<h2>Sessions</h2>\n<ul>\n" ^ implode (map entry es) ^ "</ul>";
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   205
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   206
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   207
(* theory *)
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   208
6338
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
   209
fun output_source src = implode (output_symbols (Source.exhaust (Symbol.source false src)));
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
   210
fun source src = "\n<hr>\n<pre>" ^ output_source src ^ "</pre>\n<hr>\n";
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   211
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   212
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   213
local
6376
wenzelm
parents: 6361
diff changeset
   214
  fun file (opt_ref, path, loadit) = href_opt_path opt_ref
wenzelm
parents: 6361
diff changeset
   215
    ((if not loadit then enclose "(" ")" else I) (file_path path));
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   216
6376
wenzelm
parents: 6361
diff changeset
   217
  val files = space_implode " + " o map file;
wenzelm
parents: 6361
diff changeset
   218
  val parents = space_implode " + " o map (uncurry href_opt_path o apsnd name);
6361
3a45ad4a95eb theory: include parent links;
wenzelm
parents: 6347
diff changeset
   219
6376
wenzelm
parents: 6361
diff changeset
   220
  fun theory up A =
wenzelm
parents: 6361
diff changeset
   221
    begin_document ("Theory " ^ A) ^ "\n" ^ up_link up ^
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   222
    keyword "theory" ^ " " ^ name A ^ " = ";
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   223
in
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   224
6376
wenzelm
parents: 6361
diff changeset
   225
fun begin_theory up A Bs [] body = theory up A ^ parents Bs ^ ":\n" ^ body
wenzelm
parents: 6361
diff changeset
   226
  | begin_theory up A Bs Ps body = theory up A ^ parents Bs ^ "<br>" ^ keyword "files" ^
wenzelm
parents: 6361
diff changeset
   227
      " " ^ files Ps ^ ":" ^ "\n" ^ body;
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   228
end;
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   229
6338
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
   230
val end_theory = end_document;
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   231
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   232
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   233
(* ML file *)
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   234
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   235
fun ml_file path str =
6649
2156012be986 Reimplemented graph generator.
berghofe
parents: 6405
diff changeset
   236
  begin_document ("File " ^ Url.pack path) ^
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   237
  "\n<hr>\n" ^ verbatim str ^ "\n<hr>\n" ^ end_document;
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   238
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   239
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   240
(* theorem *)
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   241
6376
wenzelm
parents: 6361
diff changeset
   242
val string_of_thm =             (* FIXME improve freeze_thaw (?) *)
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   243
  Pretty.setmp_margin 80 Pretty.string_of o
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   244
    Display.pretty_thm_no_quote o #1 o Drule.freeze_thaw;
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   245
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   246
fun thm th = preform (prefix_lines "  " (html_mode string_of_thm th));
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   247
fun theorem a th = para (keyword "theorem" ^ " " ^ name (a ^ ":") ^ "\n" ^ thm th);
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   248
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   249
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   250
(* section *)
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   251
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   252
fun section heading = "\n\n<h2>" ^ plain heading ^ "</h2>\n";
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   253
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   254
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   255
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   256
(** theory setup **)
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   257
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   258
val setup =
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   259
 [Theory.add_mode_tokentrfuns htmlN html_trans];
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   260
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   261
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   262
end;