src/Pure/Thy/html.ML
author wenzelm
Tue, 10 Jul 2007 16:45:06 +0200
changeset 23703 1b6a2c119151
parent 23622 8ce09f692653
child 23724 6e95ed5f64da
permissions -rw-r--r--
Markup.add_mode;
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
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
     4
9415
daa2296f23ea removed all_sessions;
wenzelm
parents: 9045
diff changeset
     5
HTML presentation elements.
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
23622
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
    10
  type text = string
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    11
  val plain: string -> text
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    12
  val name: string -> text
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    13
  val keyword: string -> text
23622
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
    14
  val command: string -> text
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    15
  val file_name: string -> text
6649
2156012be986 Reimplemented graph generator.
berghofe
parents: 6405
diff changeset
    16
  val file_path: Url.T -> text
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    17
  val href_name: string -> text -> text
6649
2156012be986 Reimplemented graph generator.
berghofe
parents: 6405
diff changeset
    18
  val href_path: Url.T -> text -> text
6376
wenzelm
parents: 6361
diff changeset
    19
  val href_opt_name: string option -> text -> text
6649
2156012be986 Reimplemented graph generator.
berghofe
parents: 6405
diff changeset
    20
  val href_opt_path: Url.T option -> text -> text
6376
wenzelm
parents: 6361
diff changeset
    21
  val para: text -> text
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    22
  val preform: text -> text
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    23
  val verbatim: string -> text
17470
6e9d910c3837 added with_charset: string -> ('a -> 'b) -> 'a -> 'b;
wenzelm
parents: 17412
diff changeset
    24
  val with_charset: string -> ('a -> 'b) -> 'a -> 'b
17080
c0c213a8f39c begin_index: list of docs;
wenzelm
parents: 16267
diff changeset
    25
  val begin_index: Url.T * string -> Url.T * string -> (Url.T * string) list -> Url.T -> text
6338
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
    26
  val end_index: text
9415
daa2296f23ea removed all_sessions;
wenzelm
parents: 9045
diff changeset
    27
  val applet_pages: string -> Url.T * string -> (string * string) list
6649
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
8190
wenzelm
parents: 8088
diff changeset
    30
  val verbatim_source: Symbol.symbol list -> text
6649
2156012be986 Reimplemented graph generator.
berghofe
parents: 6405
diff changeset
    31
  val begin_theory: Url.T * string -> string -> (Url.T option * string) list ->
7408
1ec1567c1307 added theorems;
wenzelm
parents: 6754
diff changeset
    32
    (Url.T option * Url.T * bool option) 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
22122
58f846cc5c3d results: proper context;
wenzelm
parents: 21858
diff changeset
    35
  val results: Proof.context -> string -> (string * thm list) list -> text
8088
6ae943d080de chapter;
wenzelm
parents: 7831
diff changeset
    36
  val chapter: string -> text
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    37
  val section: string -> text
7634
c326808da921 more sections;
wenzelm
parents: 7572
diff changeset
    38
  val subsection: string -> text
c326808da921 more sections;
wenzelm
parents: 7572
diff changeset
    39
  val subsubsection: string -> text
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    40
end;
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    41
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    42
structure HTML: HTML =
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    43
struct
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    44
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    45
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    46
(** HTML print modes **)
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    47
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    48
(* mode *)
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    49
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    50
val htmlN = "HTML";
10573
1751ab881289 append print modes;
wenzelm
parents: 9963
diff changeset
    51
fun html_mode f x = setmp print_mode (htmlN :: ! print_mode) f x;
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    52
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    53
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    54
(* symbol output *)
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
    55
6338
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
    56
local
16196
abff174ba569 html_syms table;
wenzelm
parents: 15801
diff changeset
    57
  val html_syms = Symtab.make
23622
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
    58
   [("\\<spacespace>", (2, "&nbsp;&nbsp;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
    59
    ("\\<exclamdown>", (1, "&iexcl;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
    60
    ("\\<cent>", (1, "&cent;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
    61
    ("\\<pounds>", (1, "&pound;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
    62
    ("\\<currency>", (1, "&curren;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
    63
    ("\\<yen>", (1, "&yen;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
    64
    ("\\<bar>", (1, "&brvbar;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
    65
    ("\\<section>", (1, "&sect;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
    66
    ("\\<dieresis>", (1, "&uml;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
    67
    ("\\<copyright>", (1, "&copy;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
    68
    ("\\<ordfeminine>", (1, "&ordf;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
    69
    ("\\<guillemotleft>", (1, "&laquo;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
    70
    ("\\<not>", (1, "&not;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
    71
    ("\\<hyphen>", (1, "&shy;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
    72
    ("\\<registered>", (1, "&reg;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
    73
    ("\\<inverse>", (1, "&macr;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
    74
    ("\\<degree>", (1, "&deg;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
    75
    ("\\<plusminus>", (1, "&plusmn;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
    76
    ("\\<twosuperior>", (1, "&sup2;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
    77
    ("\\<threesuperior>", (1, "&sup3;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
    78
    ("\\<acute>", (1, "&acute;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
    79
    ("\\<paragraph>", (1, "&para;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
    80
    ("\\<cdot>", (1, "&middot;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
    81
    ("\\<cedilla>", (1, "&cedil;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
    82
    ("\\<onesuperior>", (1, "&sup1;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
    83
    ("\\<ordmasculine>", (1, "&ordm;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
    84
    ("\\<guillemotright>", (1, "&raquo;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
    85
    ("\\<onequarter>", (1, "&frac14;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
    86
    ("\\<onehalf>", (1, "&frac12;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
    87
    ("\\<threequarters>", (1, "&frac34;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
    88
    ("\\<questiondown>", (1, "&iquest;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
    89
    ("\\<times>", (1, "&times;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
    90
    ("\\<div>", (1, "&divide;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
    91
    ("\\<circ>", (1, "o")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
    92
    ("\\<Alpha>", (1, "&Alpha;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
    93
    ("\\<Beta>", (1, "&Beta;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
    94
    ("\\<Gamma>", (1, "&Gamma;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
    95
    ("\\<Delta>", (1, "&Delta;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
    96
    ("\\<Epsilon>", (1, "&Epsilon;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
    97
    ("\\<Zeta>", (1, "&Zeta;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
    98
    ("\\<Eta>", (1, "&Eta;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
    99
    ("\\<Theta>", (1, "&Theta;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   100
    ("\\<Iota>", (1, "&Iota;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   101
    ("\\<Kappa>", (1, "&Kappa;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   102
    ("\\<Lambda>", (1, "&Lambda;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   103
    ("\\<Mu>", (1, "&Mu;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   104
    ("\\<Nu>", (1, "&Nu;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   105
    ("\\<Xi>", (1, "&Xi;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   106
    ("\\<Omicron>", (1, "&Omicron;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   107
    ("\\<Pi>", (1, "&Pi;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   108
    ("\\<Rho>", (1, "&Rho;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   109
    ("\\<Sigma>", (1, "&Sigma;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   110
    ("\\<Tau>", (1, "&Tau;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   111
    ("\\<Upsilon>", (1, "&Upsilon;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   112
    ("\\<Phi>", (1, "&Phi;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   113
    ("\\<Chi>", (1, "&Chi;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   114
    ("\\<Psi>", (1, "&Psi;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   115
    ("\\<Omega>", (1, "&Omega;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   116
    ("\\<alpha>", (1, "&alpha;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   117
    ("\\<beta>", (1, "&beta;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   118
    ("\\<gamma>", (1, "&gamma;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   119
    ("\\<delta>", (1, "&delta;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   120
    ("\\<epsilon>", (1, "&epsilon;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   121
    ("\\<zeta>", (1, "&zeta;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   122
    ("\\<eta>", (1, "&eta;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   123
    ("\\<theta>", (1, "&thetasym;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   124
    ("\\<iota>", (1, "&iota;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   125
    ("\\<kappa>", (1, "&kappa;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   126
    ("\\<lambda>", (1, "&lambda;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   127
    ("\\<mu>", (1, "&mu;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   128
    ("\\<nu>", (1, "&nu;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   129
    ("\\<xi>", (1, "&xi;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   130
    ("\\<omicron>", (1, "&omicron;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   131
    ("\\<pi>", (1, "&pi;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   132
    ("\\<rho>", (1, "&rho;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   133
    ("\\<sigma>", (1, "&sigma;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   134
    ("\\<tau>", (1, "&tau;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   135
    ("\\<upsilon>", (1, "&upsilon;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   136
    ("\\<phi>", (1, "&phi;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   137
    ("\\<chi>", (1, "&chi;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   138
    ("\\<psi>", (1, "&psi;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   139
    ("\\<omega>", (1, "&omega;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   140
    ("\\<bullet>", (1, "&bull;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   141
    ("\\<dots>", (1, "&hellip;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   142
    ("\\<Re>", (1, "&real;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   143
    ("\\<Im>", (1, "&image;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   144
    ("\\<wp>", (1, "&weierp;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   145
    ("\\<forall>", (1, "&forall;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   146
    ("\\<partial>", (1, "&part;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   147
    ("\\<exists>", (1, "&exist;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   148
    ("\\<emptyset>", (1, "&empty;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   149
    ("\\<nabla>", (1, "&nabla;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   150
    ("\\<in>", (1, "&isin;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   151
    ("\\<notin>", (1, "&notin;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   152
    ("\\<Prod>", (1, "&prod;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   153
    ("\\<Sum>", (1, "&sum;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   154
    ("\\<star>", (1, "&lowast;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   155
    ("\\<propto>", (1, "&prop;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   156
    ("\\<infinity>", (1, "&infin;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   157
    ("\\<angle>", (1, "&ang;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   158
    ("\\<and>", (1, "&and;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   159
    ("\\<or>", (1, "&or;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   160
    ("\\<inter>", (1, "&cap;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   161
    ("\\<union>", (1, "&cup;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   162
    ("\\<sim>", (1, "&sim;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   163
    ("\\<cong>", (1, "&cong;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   164
    ("\\<approx>", (1, "&asymp;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   165
    ("\\<noteq>", (1, "&ne;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   166
    ("\\<equiv>", (1, "&equiv;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   167
    ("\\<le>", (1, "&le;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   168
    ("\\<ge>", (1, "&ge;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   169
    ("\\<subset>", (1, "&sub;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   170
    ("\\<supset>", (1, "&sup;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   171
    ("\\<subseteq>", (1, "&sube;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   172
    ("\\<supseteq>", (1, "&supe;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   173
    ("\\<oplus>", (1, "&oplus;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   174
    ("\\<otimes>", (1, "&otimes;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   175
    ("\\<bottom>", (1, "&perp;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   176
    ("\\<lceil>", (1, "&lceil;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   177
    ("\\<rceil>", (1, "&rceil;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   178
    ("\\<lfloor>", (1, "&lfloor;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   179
    ("\\<rfloor>", (1, "&rfloor;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   180
    ("\\<langle>", (1, "&lang;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   181
    ("\\<rangle>", (1, "&rang;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   182
    ("\\<lozenge>", (1, "&loz;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   183
    ("\\<spadesuit>", (1, "&spades;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   184
    ("\\<clubsuit>", (1, "&clubs;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   185
    ("\\<heartsuit>", (1, "&hearts;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   186
    ("\\<diamondsuit>", (1, "&diams;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   187
    ("\\<lbrakk>", (2, "[|")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   188
    ("\\<rbrakk>", (2, "|]")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   189
    ("\\<Longrightarrow>", (3, "==&gt;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   190
    ("\\<Rightarrow>", (2, "=&gt;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   191
    ("\\<And>", (2, "!!")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   192
    ("\\<Colon>", (2, "::")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   193
    ("\\<lparr>", (2, "(|")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   194
    ("\\<rparr>", (2, "|)),")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   195
    ("\\<longleftrightarrow>", (3, "&lt;-&gt;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   196
    ("\\<longrightarrow>", (3, "--&gt;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   197
    ("\\<rightarrow>", (2, "-&gt;")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   198
    ("\\<^bsub>", (0, "<sub>")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   199
    ("\\<^esub>", (0, "</sub>")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   200
    ("\\<^bsup>", (0, "<sup>")),
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   201
    ("\\<^esup>", (0, "</sup>"))];
17178
18a98ecc6821 output \<^loc> as 'loc' span;
wenzelm
parents: 17116
diff changeset
   202
18a98ecc6821 output \<^loc> as 'loc' span;
wenzelm
parents: 17116
diff changeset
   203
  val escape = fn "<" => "&lt;" | ">" => "&gt;" | "&" => "&amp;" | c => c;
16196
abff174ba569 html_syms table;
wenzelm
parents: 15801
diff changeset
   204
abff174ba569 html_syms table;
wenzelm
parents: 15801
diff changeset
   205
  fun output_sym s =
23622
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   206
    if Symbol.is_raw s then (1, Symbol.decode_raw s)
20742
2233f6afc491 reverted to 1.58;
wenzelm
parents: 20576
diff changeset
   207
    else
2233f6afc491 reverted to 1.58;
wenzelm
parents: 20576
diff changeset
   208
      (case Symtab.lookup html_syms s of SOME x => x
23622
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   209
      | NONE => (size s, translate_string escape s));
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   210
17178
18a98ecc6821 output \<^loc> as 'loc' span;
wenzelm
parents: 17116
diff changeset
   211
  fun output_sub s = apsnd (enclose "<sub>" "</sub>") (output_sym s);
18a98ecc6821 output \<^loc> as 'loc' span;
wenzelm
parents: 17116
diff changeset
   212
  fun output_sup s = apsnd (enclose "<sup>" "</sup>") (output_sym s);
18a98ecc6821 output \<^loc> as 'loc' span;
wenzelm
parents: 17116
diff changeset
   213
  fun output_loc s = apsnd (enclose "<span class=\"loc\">" "</span>") (output_sym s);
14534
7a46bdcd92f2 treat sub/super scripts
kleing
parents: 14083
diff changeset
   214
17178
18a98ecc6821 output \<^loc> as 'loc' span;
wenzelm
parents: 17116
diff changeset
   215
  fun output_syms ("\\<^sub>" :: s :: ss) = output_sub s :: output_syms ss
18a98ecc6821 output \<^loc> as 'loc' span;
wenzelm
parents: 17116
diff changeset
   216
    | output_syms ("\\<^isub>" :: s :: ss) = output_sub s :: output_syms ss
18a98ecc6821 output \<^loc> as 'loc' span;
wenzelm
parents: 17116
diff changeset
   217
    | output_syms ("\\<^sup>" :: s :: ss) = output_sup s :: output_syms ss
18a98ecc6821 output \<^loc> as 'loc' span;
wenzelm
parents: 17116
diff changeset
   218
    | output_syms ("\\<^isup>" :: s :: ss) = output_sup s :: output_syms ss
18a98ecc6821 output \<^loc> as 'loc' span;
wenzelm
parents: 17116
diff changeset
   219
    | output_syms ("\\<^loc>" :: s :: ss) = output_loc s :: output_syms ss
18a98ecc6821 output \<^loc> as 'loc' span;
wenzelm
parents: 17116
diff changeset
   220
    | output_syms (s :: ss) = output_sym s :: output_syms ss
18a98ecc6821 output \<^loc> as 'loc' span;
wenzelm
parents: 17116
diff changeset
   221
    | output_syms [] = [];
6338
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
   222
in
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   223
6338
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
   224
fun output_width str =
19305
5c16895d548b avoid polymorphic equality;
wenzelm
parents: 19265
diff changeset
   225
  if not (exists_string (fn s => s = "\\" orelse s = "<" orelse s = ">" orelse s = "&") str)
23622
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   226
  then Output.default_output str
6338
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
   227
  else
17178
18a98ecc6821 output \<^loc> as 'loc' span;
wenzelm
parents: 17116
diff changeset
   228
    let val (syms, width) = fold_map (fn (w, s) => fn width => (s, w + width))
23622
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   229
      (output_syms (Symbol.explode str)) 0
17178
18a98ecc6821 output \<^loc> as 'loc' span;
wenzelm
parents: 17116
diff changeset
   230
    in (implode syms, width) end;
6338
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
   231
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
   232
val output = #1 o output_width;
17178
18a98ecc6821 output \<^loc> as 'loc' span;
wenzelm
parents: 17116
diff changeset
   233
val output_symbols = map #2 o output_syms;
6338
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
   234
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
   235
end;
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
   236
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   237
23622
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   238
(* markup and token translations *)
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   239
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   240
fun span s = ("<span class=" ^ Library.quote s ^ ">", "</span>");
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   241
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   242
fun style s = apfst (span s |-> enclose) o output_width;
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   243
23622
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   244
fun free_or_skolem x =
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   245
  (case try Name.dest_skolem x of
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   246
    NONE => style "free" x
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   247
  | SOME x' => style "skolem" x');
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   248
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   249
fun var_or_skolem s =
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   250
  (case Syntax.read_variable s of
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   251
    SOME (x, i) =>
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   252
      (case try Name.dest_skolem x of
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   253
        NONE => style "var" s
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   254
      | SOME x' => style "skolem"
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   255
          (setmp show_question_marks true Term.string_of_vname (x', i)))
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   256
  | NONE => style "var" s);
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   257
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   258
val html_trans =
14541
0a7743e2f8dd use css
kleing
parents: 14534
diff changeset
   259
 [("class", style "tclass"),
0a7743e2f8dd use css
kleing
parents: 14534
diff changeset
   260
  ("tfree", style "tfree"),
0a7743e2f8dd use css
kleing
parents: 14534
diff changeset
   261
  ("tvar",  style "tvar"),
23622
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   262
  ("free",  free_or_skolem),
14541
0a7743e2f8dd use css
kleing
parents: 14534
diff changeset
   263
  ("bound", style "bound"),
23622
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   264
  ("var",   var_or_skolem),
14541
0a7743e2f8dd use css
kleing
parents: 14534
diff changeset
   265
  ("xstr",  style "xstr")];
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   266
22796
34c316d7b630 renamed some old names Theory.xxx to Sign.xxx;
wenzelm
parents: 22122
diff changeset
   267
val _ = Context.add_setup (Sign.add_mode_tokentrfuns htmlN html_trans);
15801
d2f5ca3c048d superceded by Pure.thy and CPure.thy;
wenzelm
parents: 15531
diff changeset
   268
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   269
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   270
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   271
(** HTML markup **)
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   272
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   273
type text = string;
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
(* atoms *)
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   277
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   278
val plain = output;
19265
cae36e16f3c0 Output.add_mode: keyword component;
wenzelm
parents: 18708
diff changeset
   279
val name = enclose "<span class=\"name\">" "</span>" o output;
cae36e16f3c0 Output.add_mode: keyword component;
wenzelm
parents: 18708
diff changeset
   280
val keyword = enclose "<span class=\"keyword\">" "</span>" o output;
23622
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   281
val command = enclose "<span class=\"command\">" "</span>" o output;
19265
cae36e16f3c0 Output.add_mode: keyword component;
wenzelm
parents: 18708
diff changeset
   282
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
   283
val file_path = file_name o Url.implode;
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   284
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   285
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   286
(* misc *)
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   287
14598
7009f59711e3 Replaced quote by Library.quote, since quote now refers to Symbol.quote
berghofe
parents: 14571
diff changeset
   288
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
   289
fun href_path path txt = href_name (Url.implode path) txt;
6376
wenzelm
parents: 6361
diff changeset
   290
15531
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15336
diff changeset
   291
fun href_opt_name NONE txt = txt
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15336
diff changeset
   292
  | href_opt_name (SOME s) txt = href_name s txt;
6376
wenzelm
parents: 6361
diff changeset
   293
15531
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15336
diff changeset
   294
fun href_opt_path NONE txt = txt
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15336
diff changeset
   295
  | href_opt_path (SOME p) txt = href_path p txt;
6376
wenzelm
parents: 6361
diff changeset
   296
12413
f879fcc9412d tuned line breaks in HTML source;
wenzelm
parents: 12151
diff changeset
   297
fun para txt = "\n<p>" ^ txt ^ "</p>\n";
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   298
fun preform txt = "<pre>" ^ txt ^ "</pre>";
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   299
val verbatim = preform o output;
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   300
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   301
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   302
(* document *)
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   303
17470
6e9d910c3837 added with_charset: string -> ('a -> 'b) -> 'a -> 'b;
wenzelm
parents: 17412
diff changeset
   304
val charset = ref "iso-8859-1";
6e9d910c3837 added with_charset: string -> ('a -> 'b) -> 'a -> 'b;
wenzelm
parents: 17412
diff changeset
   305
fun with_charset s = setmp charset s;
6e9d910c3837 added with_charset: string -> ('a -> 'b) -> 'a -> 'b;
wenzelm
parents: 17412
diff changeset
   306
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   307
fun begin_document title =
17080
c0c213a8f39c begin_index: list of docs;
wenzelm
parents: 16267
diff changeset
   308
  "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \
c0c213a8f39c begin_index: list of docs;
wenzelm
parents: 16267
diff changeset
   309
  \\"http://www.w3.org/TR/html4/loose.dtd\">\n\
14083
aed5d25c4a0c Added DOCTYPE and Content-type to HTML documents.
webertj
parents: 13531
diff changeset
   310
  \\n\
aed5d25c4a0c Added DOCTYPE and Content-type to HTML documents.
webertj
parents: 13531
diff changeset
   311
  \<html>\n\
6405
wenzelm
parents: 6376
diff changeset
   312
  \<head>\n\
17470
6e9d910c3837 added with_charset: string -> ('a -> 'b) -> 'a -> 'b;
wenzelm
parents: 17412
diff changeset
   313
  \<meta http-equiv=\"Content-Type\" content=\"text/html; charset=" ^ ! charset ^ "\">\n\
6405
wenzelm
parents: 6376
diff changeset
   314
  \<title>" ^ plain (title ^ " (" ^ version ^ ")") ^ "</title>\n\
14541
0a7743e2f8dd use css
kleing
parents: 14534
diff changeset
   315
  \<link rel=\"stylesheet\" type=\"text/css\" href=\"isabelle.css\">\n\
6405
wenzelm
parents: 6376
diff changeset
   316
  \</head>\n\
wenzelm
parents: 6376
diff changeset
   317
  \\n\
wenzelm
parents: 6376
diff changeset
   318
  \<body>\n\
14541
0a7743e2f8dd use css
kleing
parents: 14534
diff changeset
   319
  \<div class=\"head\">\
6405
wenzelm
parents: 6376
diff changeset
   320
  \<h1>" ^ plain title ^ "</h1>\n"
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   321
14541
0a7743e2f8dd use css
kleing
parents: 14534
diff changeset
   322
val end_document = "\n</div>\n</body>\n</html>\n";
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   323
6754
c23c542a32e5 tuned markup;
wenzelm
parents: 6649
diff changeset
   324
fun gen_link how (path, name) = para (href_path path how ^ " to index of " ^ plain name);
c23c542a32e5 tuned markup;
wenzelm
parents: 6649
diff changeset
   325
val up_link = gen_link "Up";
c23c542a32e5 tuned markup;
wenzelm
parents: 6649
diff changeset
   326
val back_link = gen_link "Back";
6338
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
   327
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
   328
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
   329
(* session index *)
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
   330
17080
c0c213a8f39c begin_index: list of docs;
wenzelm
parents: 16267
diff changeset
   331
fun begin_index up (index_path, session) docs graph =
6754
c23c542a32e5 tuned markup;
wenzelm
parents: 6649
diff changeset
   332
  begin_document ("Index of " ^ session) ^ up_link up ^
c23c542a32e5 tuned markup;
wenzelm
parents: 6649
diff changeset
   333
  para ("View " ^ href_path graph "theory dependencies" ^
17080
c0c213a8f39c begin_index: list of docs;
wenzelm
parents: 16267
diff changeset
   334
    implode (map (fn (p, name) => "<br>\nView " ^ href_path p name) docs)) ^
14541
0a7743e2f8dd use css
kleing
parents: 14534
diff changeset
   335
  "\n</div>\n<hr>\n<div class=\"theories\">\n<h2>Theories</h2>\n<ul>\n";
6338
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
   336
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
   337
val end_index = end_document;
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
   338
6649
2156012be986 Reimplemented graph generator.
berghofe
parents: 6405
diff changeset
   339
fun choice chs s = space_implode " " (map (fn (s', lnk) =>
2156012be986 Reimplemented graph generator.
berghofe
parents: 6405
diff changeset
   340
  enclose "[" "]" (if s = s' then keyword s' else href_name lnk s')) chs);
2156012be986 Reimplemented graph generator.
berghofe
parents: 6405
diff changeset
   341
9415
daa2296f23ea removed all_sessions;
wenzelm
parents: 9045
diff changeset
   342
fun applet_pages session back =
6649
2156012be986 Reimplemented graph generator.
berghofe
parents: 6405
diff changeset
   343
  let
9415
daa2296f23ea removed all_sessions;
wenzelm
parents: 9045
diff changeset
   344
    val sizes =
daa2296f23ea removed all_sessions;
wenzelm
parents: 9045
diff changeset
   345
     [("small", "small.html", ("500", "400")),
daa2296f23ea removed all_sessions;
wenzelm
parents: 9045
diff changeset
   346
      ("medium", "medium.html", ("650", "520")),
daa2296f23ea removed all_sessions;
wenzelm
parents: 9045
diff changeset
   347
      ("large", "large.html", ("800", "640"))];
6649
2156012be986 Reimplemented graph generator.
berghofe
parents: 6405
diff changeset
   348
9415
daa2296f23ea removed all_sessions;
wenzelm
parents: 9045
diff changeset
   349
    fun applet_page (size, name, (width, height)) =
6754
c23c542a32e5 tuned markup;
wenzelm
parents: 6649
diff changeset
   350
      let
c23c542a32e5 tuned markup;
wenzelm
parents: 6649
diff changeset
   351
        val browser_size = "Set browser size: " ^
9415
daa2296f23ea removed all_sessions;
wenzelm
parents: 9045
diff changeset
   352
          choice (map (fn (y, z, _) => (y, z)) sizes) size;
6754
c23c542a32e5 tuned markup;
wenzelm
parents: 6649
diff changeset
   353
      in
c23c542a32e5 tuned markup;
wenzelm
parents: 6649
diff changeset
   354
        (name, begin_document ("Theory dependencies of " ^ session) ^
c23c542a32e5 tuned markup;
wenzelm
parents: 6649
diff changeset
   355
          back_link back ^
9415
daa2296f23ea removed all_sessions;
wenzelm
parents: 9045
diff changeset
   356
          para browser_size ^
17080
c0c213a8f39c begin_index: list of docs;
wenzelm
parents: 16267
diff changeset
   357
          "\n</div>\n<hr>\n<div class=\"graphbrowser\">\n\
c0c213a8f39c begin_index: list of docs;
wenzelm
parents: 16267
diff changeset
   358
          \<applet code=\"GraphBrowser/GraphBrowser.class\" \
14541
0a7743e2f8dd use css
kleing
parents: 14534
diff changeset
   359
          \archive=\"GraphBrowser.jar\" \
9045
a5bfcd4c2a5e Removed codebase attribute from applet_pages.
berghofe
parents: 8808
diff changeset
   360
          \width=" ^ width ^ " height=" ^ height ^ ">\n\
9415
daa2296f23ea removed all_sessions;
wenzelm
parents: 9045
diff changeset
   361
          \<param name=\"graphfile\" value=\"" ^ "session.graph" ^ "\">\n\
6754
c23c542a32e5 tuned markup;
wenzelm
parents: 6649
diff changeset
   362
          \</applet>\n<hr>" ^ end_document)
6649
2156012be986 Reimplemented graph generator.
berghofe
parents: 6405
diff changeset
   363
      end;
9415
daa2296f23ea removed all_sessions;
wenzelm
parents: 9045
diff changeset
   364
  in map applet_page sizes end;
6649
2156012be986 Reimplemented graph generator.
berghofe
parents: 6405
diff changeset
   365
2156012be986 Reimplemented graph generator.
berghofe
parents: 6405
diff changeset
   366
6405
wenzelm
parents: 6376
diff changeset
   367
fun entry (p, s) = "<li>" ^ href_path p (plain s) ^ "\n";
wenzelm
parents: 6376
diff changeset
   368
6338
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
   369
val theory_entry = entry;
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
   370
6405
wenzelm
parents: 6376
diff changeset
   371
fun session_entries [] = "</ul>"
wenzelm
parents: 6376
diff changeset
   372
  | session_entries es =
17080
c0c213a8f39c begin_index: list of docs;
wenzelm
parents: 16267
diff changeset
   373
      "</ul>\n</div>\n<hr>\n<div class=\"sessions\">\n\
c0c213a8f39c begin_index: list of docs;
wenzelm
parents: 16267
diff changeset
   374
      \<h2>Sessions</h2>\n<ul>\n" ^ implode (map entry es) ^ "</ul>";
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   375
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   376
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   377
(* theory *)
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   378
14571
b88d5f9e02e1 fixed width;
wenzelm
parents: 14565
diff changeset
   379
fun verbatim_source ss =
b88d5f9e02e1 fixed width;
wenzelm
parents: 14565
diff changeset
   380
  "\n</div>\n<hr>\n<div class=\"source\">\n<pre>" ^
17178
18a98ecc6821 output \<^loc> as 'loc' span;
wenzelm
parents: 17116
diff changeset
   381
  implode (output_symbols ss) ^
14571
b88d5f9e02e1 fixed width;
wenzelm
parents: 14565
diff changeset
   382
  "</pre>\n</div>\n<hr>\n<div class=\"theorems\">\n";
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   383
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   384
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   385
local
15531
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15336
diff changeset
   386
  fun encl NONE = enclose "[" "]"
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15336
diff changeset
   387
    | encl (SOME false) = enclose "(" ")"
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15336
diff changeset
   388
    | encl (SOME true) = I;
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   389
7408
1ec1567c1307 added theorems;
wenzelm
parents: 6754
diff changeset
   390
  fun file (opt_ref, path, loadit) = href_opt_path opt_ref (encl loadit (file_path path));
6361
3a45ad4a95eb theory: include parent links;
wenzelm
parents: 6347
diff changeset
   391
6376
wenzelm
parents: 6361
diff changeset
   392
  fun theory up A =
wenzelm
parents: 6361
diff changeset
   393
    begin_document ("Theory " ^ A) ^ "\n" ^ up_link up ^
23622
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   394
    command "theory" ^ " " ^ name A;
16267
0773b17922d8 present new-style theory header, with 'imports' and 'uses';
wenzelm
parents: 16196
diff changeset
   395
0773b17922d8 present new-style theory header, with 'imports' and 'uses';
wenzelm
parents: 16196
diff changeset
   396
  fun imports Bs =
0773b17922d8 present new-style theory header, with 'imports' and 'uses';
wenzelm
parents: 16196
diff changeset
   397
    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
   398
17209
2ae243868a62 added line break for 'uses';
wenzelm
parents: 17178
diff changeset
   399
  fun uses Ps = keyword "uses" ^ " " ^ space_implode " " (map file Ps) ^ "<br>\n";
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   400
in
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   401
16267
0773b17922d8 present new-style theory header, with 'imports' and 'uses';
wenzelm
parents: 16196
diff changeset
   402
fun begin_theory up A Bs Ps body =
0773b17922d8 present new-style theory header, with 'imports' and 'uses';
wenzelm
parents: 16196
diff changeset
   403
  theory up A ^ "<br>\n" ^
0773b17922d8 present new-style theory header, with 'imports' and 'uses';
wenzelm
parents: 16196
diff changeset
   404
  imports Bs ^ "<br>\n" ^
0773b17922d8 present new-style theory header, with 'imports' and 'uses';
wenzelm
parents: 16196
diff changeset
   405
  (if null Ps then "" else uses Ps) ^
0773b17922d8 present new-style theory header, with 'imports' and 'uses';
wenzelm
parents: 16196
diff changeset
   406
  keyword "begin" ^ "<br>\n" ^
0773b17922d8 present new-style theory header, with 'imports' and 'uses';
wenzelm
parents: 16196
diff changeset
   407
  body;
0773b17922d8 present new-style theory header, with 'imports' and 'uses';
wenzelm
parents: 16196
diff changeset
   408
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   409
end;
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   410
6338
bf0d22535e47 output: some symbol translations;
wenzelm
parents: 6324
diff changeset
   411
val end_theory = end_document;
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   412
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   413
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   414
(* ML file *)
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   415
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   416
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
   417
  begin_document ("File " ^ Url.implode path) ^
14571
b88d5f9e02e1 fixed width;
wenzelm
parents: 14565
diff changeset
   418
  "\n</div>\n<hr><div class=\"mlsource\">\n" ^
b88d5f9e02e1 fixed width;
wenzelm
parents: 14565
diff changeset
   419
  verbatim str ^
b88d5f9e02e1 fixed width;
wenzelm
parents: 14565
diff changeset
   420
  "\n</div>\n<hr>\n<div class=\"mlfooter\">\n" ^
14541
0a7743e2f8dd use css
kleing
parents: 14534
diff changeset
   421
  end_document;
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   422
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   423
7408
1ec1567c1307 added theorems;
wenzelm
parents: 6754
diff changeset
   424
(* theorems *)
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   425
7572
6e6dafacbc28 present results;
wenzelm
parents: 7408
diff changeset
   426
local
6e6dafacbc28 present results;
wenzelm
parents: 7408
diff changeset
   427
22122
58f846cc5c3d results: proper context;
wenzelm
parents: 21858
diff changeset
   428
fun string_of_thm ctxt =
14839
c994f1c57fc7 handle raw symbols; Output.add_mode; more robust handling of sub/superscript;
wenzelm
parents: 14775
diff changeset
   429
  Output.output o Pretty.setmp_margin 80 Pretty.string_of o
22122
58f846cc5c3d results: proper context;
wenzelm
parents: 21858
diff changeset
   430
    setmp show_question_marks false (ProofContext.pretty_thm ctxt);
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   431
22122
58f846cc5c3d results: proper context;
wenzelm
parents: 21858
diff changeset
   432
fun thm ctxt th = preform (prefix_lines "  " (html_mode (string_of_thm ctxt) th));
7408
1ec1567c1307 added theorems;
wenzelm
parents: 6754
diff changeset
   433
7572
6e6dafacbc28 present results;
wenzelm
parents: 7408
diff changeset
   434
fun thm_name "" = ""
6e6dafacbc28 present results;
wenzelm
parents: 7408
diff changeset
   435
  | thm_name a = " " ^ name (a ^ ":");
6e6dafacbc28 present results;
wenzelm
parents: 7408
diff changeset
   436
6e6dafacbc28 present results;
wenzelm
parents: 7408
diff changeset
   437
in
6e6dafacbc28 present results;
wenzelm
parents: 7408
diff changeset
   438
23622
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   439
fun result ctxt k (a, ths) = para (cat_lines ((command k ^ thm_name a) :: map (thm ctxt) ths));
7572
6e6dafacbc28 present results;
wenzelm
parents: 7408
diff changeset
   440
22122
58f846cc5c3d results: proper context;
wenzelm
parents: 21858
diff changeset
   441
fun results _ _ [] = ""
58f846cc5c3d results: proper context;
wenzelm
parents: 21858
diff changeset
   442
  | results ctxt k (res :: ress) = cat_lines (result ctxt k res :: map (result ctxt "and") ress);
7572
6e6dafacbc28 present results;
wenzelm
parents: 7408
diff changeset
   443
6e6dafacbc28 present results;
wenzelm
parents: 7408
diff changeset
   444
end;
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   445
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   446
7634
c326808da921 more sections;
wenzelm
parents: 7572
diff changeset
   447
(* sections *)
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   448
8088
6ae943d080de chapter;
wenzelm
parents: 7831
diff changeset
   449
fun chapter heading = "\n\n<h1>" ^ plain heading ^ "</h1>\n";
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   450
fun section heading = "\n\n<h2>" ^ plain heading ^ "</h2>\n";
7634
c326808da921 more sections;
wenzelm
parents: 7572
diff changeset
   451
fun subsection heading = "\n\n<h3>" ^ plain heading ^ "</h3>\n";
c326808da921 more sections;
wenzelm
parents: 7572
diff changeset
   452
fun subsubsection heading = "\n\n<h4>" ^ plain heading ^ "</h4>\n";
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   453
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   454
19265
cae36e16f3c0 Output.add_mode: keyword component;
wenzelm
parents: 18708
diff changeset
   455
(* mode output *)
cae36e16f3c0 Output.add_mode: keyword component;
wenzelm
parents: 18708
diff changeset
   456
23622
8ce09f692653 simplified pretty token metric: type int;
wenzelm
parents: 22796
diff changeset
   457
val _ = Output.add_mode htmlN output_width Symbol.encode_raw;
23703
1b6a2c119151 Markup.add_mode;
wenzelm
parents: 23622
diff changeset
   458
val _ = Markup.add_mode htmlN (span o #1);
19265
cae36e16f3c0 Output.add_mode: keyword component;
wenzelm
parents: 18708
diff changeset
   459
6324
3b7111b360b1 HTML markup elements.
wenzelm
parents:
diff changeset
   460
end;