Gitlab is now running v13.9.0 - More info -> here <-

Commit 89a58f33 authored by Philippe Veber's avatar Philippe Veber

tk/Note: option for croquis size configuration

parent 5b1f5f2d
......@@ -5,7 +5,11 @@ type elt =
| Dataframe of Dataframe.t * (string * Dataframe.html_formatter) list
| Png of string
| Svg of string
| Croquis of Biotk_croquis.Croquis.Picture.t
| Croquis of {
picture : Biotk_croquis.Croquis.Picture.t ;
width : float option ;
height : float option ;
}
type t = {
title : string ;
......@@ -21,7 +25,7 @@ let text x = Text x
let dataframe ?(formatters = []) d = Dataframe (d, formatters)
let png fn = Png fn
let svg fn = Svg fn
let croquis c = Croquis c
let croquis ?width ?height picture = Croquis { picture ; width ; height }
let render_picture format data buf =
let format = match format with
......@@ -39,11 +43,11 @@ let render_dataframe formatters data buf =
Tyxml.Html.pp_elt () fmt (Dataframe.to_html ~formatters data) ;
Format.pp_print_flush fmt ()
let render_croquis croquis buf =
let render_croquis ?width ?height croquis buf =
let open Biotk_croquis.Croquis in
let data =
let pic_buf = Buffer.create 253 in
Layout.(render `svg (simple croquis) (`Buffer pic_buf)) ;
Layout.(render ?width ?height `svg (simple croquis) (`Buffer pic_buf)) ;
Buffer.contents pic_buf
in
render_picture `svg data buf
......@@ -65,7 +69,8 @@ let render_doc doc =
| Png fn -> render_picture_on_disk `png fn buf
| Svg fn -> render_picture_on_disk `svg fn buf
| Dataframe (data, formatters) -> render_dataframe formatters data buf
| Croquis croquis -> render_croquis croquis buf
| Croquis { width ; height ; picture } ->
render_croquis ?width ?height picture buf
) ;
Buffer.add_string buf "\n\n"
) ;
......
......@@ -11,7 +11,12 @@ val dataframe :
val png : string -> elt
val svg : string -> elt
val croquis : Biotk_croquis.Croquis.Picture.t -> elt
val croquis :
?width:float ->
?height:float ->
Biotk_croquis.Croquis.Picture.t ->
elt
val make :
?toc:bool ->
......
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