Commit a4f8dddc authored by Philippe Veber's avatar Philippe Veber
Browse files

tk/Note: support for dataframe

parent 39f20f75
......@@ -2,7 +2,7 @@ open Core_kernel
type elt =
| Text of string
| Table of (string * string list) list
| Dataframe of Dataframe.t
| Png of string
| Svg of string
| Vg of Vg.image
......@@ -18,7 +18,7 @@ let make ?(toc = false) ~title contents = {
}
let text x = Text x
let table cols = Table cols
let dataframe d = Dataframe d
let png fn = Png fn
let svg fn = Svg fn
let vg i = Vg i
......@@ -34,6 +34,10 @@ let render_picture format data buf =
let render_picture_on_disk format fn buf =
render_picture format (In_channel.read_all fn) buf
let render_dataframe data buf =
let fmt = Format.formatter_of_buffer buf in
Tyxml.Html.pp_elt () fmt (Dataframe.to_html data) ;
Format.pp_print_flush fmt ()
let header doc =
sprintf {|---
......@@ -50,7 +54,8 @@ let render_doc doc =
| Text t -> Buffer.add_string buf t
| Png fn -> render_picture_on_disk `png fn buf
| Svg fn -> render_picture_on_disk `svg fn buf
| _ -> failwith "not implemented"
| Dataframe data -> render_dataframe data buf
| Vg _ -> assert false
) ;
Buffer.add_string buf "\n\n"
) ;
......
......@@ -4,7 +4,7 @@ type elt
val text : string -> elt
val table : (string * string list) list -> elt
val dataframe : Dataframe.t -> elt
val png : string -> elt
val svg : string -> elt
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment