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