src/Pure/Thy/html.ML
changeset 54455 1d977436c1bf
parent 53194 1943db7bc34c
child 54456 f4b1440d9880
equal deleted inserted replaced
54454:044faa8a8080 54455:1d977436c1bf
    10   type text = string
    10   type text = string
    11   val plain: string -> text
    11   val plain: string -> text
    12   val name: string -> text
    12   val name: string -> text
    13   val keyword: string -> text
    13   val keyword: string -> text
    14   val command: string -> text
    14   val command: string -> text
    15   val file_name: string -> text
       
    16   val file_path: Url.T -> text
       
    17   val href_name: string -> text -> text
    15   val href_name: string -> text -> text
    18   val href_path: Url.T -> text -> text
    16   val href_path: Url.T -> text -> text
    19   val href_opt_path: Url.T option -> text -> text
    17   val href_opt_path: Url.T option -> text -> text
    20   val para: text -> text
    18   val para: text -> text
    21   val preform: text -> text
    19   val preform: text -> text
    24   val end_document: text
    22   val end_document: text
    25   val begin_session_index: string -> (Url.T * string) list -> Url.T -> text
    23   val begin_session_index: string -> (Url.T * string) list -> Url.T -> text
    26   val applet_pages: string -> Url.T * string -> (string * string) list
    24   val applet_pages: string -> Url.T * string -> (string * string) list
    27   val theory_entry: Url.T * string -> text
    25   val theory_entry: Url.T * string -> text
    28   val theory_source: text -> text
    26   val theory_source: text -> text
    29   val begin_theory: string -> (Url.T option * string) list ->
    27   val begin_theory: string -> (Url.T option * string) list -> text -> text
    30     (Url.T * Url.T * bool) list -> text -> text
       
    31   val external_file: Url.T -> string -> text
       
    32 end;
    28 end;
    33 
    29 
    34 structure HTML: HTML =
    30 structure HTML: HTML =
    35 struct
    31 struct
    36 
    32 
   244 
   240 
   245 val plain = output;
   241 val plain = output;
   246 val name = enclose "<span class=\"name\">" "</span>" o output;
   242 val name = enclose "<span class=\"name\">" "</span>" o output;
   247 val keyword = enclose "<span class=\"keyword\">" "</span>" o output;
   243 val keyword = enclose "<span class=\"keyword\">" "</span>" o output;
   248 val command = enclose "<span class=\"command\">" "</span>" o output;
   244 val command = enclose "<span class=\"command\">" "</span>" o output;
   249 val file_name = enclose "<span class=\"filename\">" "</span>" o output;
       
   250 val file_path = file_name o Url.implode;
       
   251 
   245 
   252 
   246 
   253 (* misc *)
   247 (* misc *)
   254 
   248 
   255 fun href_name s txt = "<a href=" ^ quote s ^ ">" ^ txt ^ "</a>";
   249 fun href_name s txt = "<a href=" ^ quote s ^ ">" ^ txt ^ "</a>";
   328 
   322 
   329 val theory_source = enclose
   323 val theory_source = enclose
   330   "\n</div>\n<div class=\"source\">\n<pre>"
   324   "\n</div>\n<div class=\"source\">\n<pre>"
   331   "</pre>\n";
   325   "</pre>\n";
   332 
   326 
   333 
   327 fun begin_theory A Bs body =
   334 local
   328   begin_document ("Theory " ^ A) ^ "\n" ^ command "theory" ^ " " ^ name A ^ "<br/>\n" ^
   335   fun file (href, path, loadit) =
   329   keyword "imports" ^ " " ^ space_implode " " (map (uncurry href_opt_path o apsnd name) Bs) ^
   336     href_path href (if loadit then file_path path else enclose "(" ")" (file_path path));
   330   "<br/>\n" ^ body;
   337 
       
   338   fun theory A =
       
   339     begin_document ("Theory " ^ A) ^ "\n" ^ command "theory" ^ " " ^ name A;
       
   340 
       
   341   fun imports Bs =
       
   342     keyword "imports" ^ " " ^ space_implode " " (map (uncurry href_opt_path o apsnd name) Bs);
       
   343 
       
   344   fun uses Ps = keyword "uses" ^ " " ^ space_implode " " (map file Ps) ^ "<br/>\n";
       
   345 in
       
   346 
       
   347 fun begin_theory A Bs Ps body =
       
   348   theory A ^ "<br/>\n" ^
       
   349   imports Bs ^ "<br/>\n" ^
       
   350   (if null Ps then "" else uses Ps) ^
       
   351   body;
       
   352 
   331 
   353 end;
   332 end;
   354 
       
   355 
       
   356 (* external file *)
       
   357 
       
   358 fun external_file path str =
       
   359   begin_document ("File " ^ Url.implode path) ^
       
   360   "\n</div><div class=\"external_source\">\n" ^
       
   361   verbatim str ^
       
   362   "\n</div>\n<div class=\"external_footer\">" ^
       
   363   end_document;
       
   364 
       
   365 end;