(* Michaël PÉRIN, Verimag / Université Grenoble-Alpes, Février 2017
*
* A library for generating html output
*
* - Required modules: Tricks MyList Graphics -> Color
*
* - Compilation: ocamlc Tricks.cmo MyList.cmo Graphics.cma Color.cmo html.ml
*)
open Tricks
(* TYPES *)
type content = string
type cell = content
type cells = content list
type row = content
type rows = row list
type table = content
type valeur =
| Int of int
| Option of string
| Color of Color.t
type options = (string * valeur) list
(* UNUSED ? USEFUL ?
type descriptor = {
width: int option ;
height: int option ;
bgcolor: Color.t option ;
ftcolor: Color.t option ;
font_size: int option ;
align: string option ;
valign: string option
}
let (descriptor: descriptor) = {
width = Some 10 ;
height = Some 10 ;
bgcolor = None ;
ftcolor = None ;
font_size = None ;
align = Some "center" ;
valign = Some "center" ;
}
*)
let (concat: content list -> content) = String.concat "\n"
let (valeur_to_string: valeur -> string) = fun valeur ->
match valeur with
| Int i -> string_of_int i
| Option s -> s
| Color c -> Color.color_to_html c
(* OPTIONS: algin=center color="red" *)
let (process_options: options -> string) = fun options ->
if options = []
then ""
else
let string =
options
>> (List.map (fun (name,valeur) -> name ^ "=" ^ (valeur_to_string valeur)))
>> (String.concat " ")
in " " ^ string
(* ENVIRONMENT: