FSharp.Formatting
FSharp.Formatting copied to clipboard
saveImages flag is not documented or tested
-
The
saveImagesflag came from FsLab's literate scripting. It is not documented or tested. -
The docs don't explain how to embed image outputs specifically, just some general information on extending display formatting.
Just to share what I did to embed image outputs that seems to work for me:
I wrote these functions
/// Returns the file contents as Base64 encoded string
let fileToBase64String fileName =
let bytes = System.IO.File.ReadAllBytes(fileName)
System.Convert.ToBase64String(bytes)
/// Given a PNG image file name, returns an HTML image element with the image content included as a Base64 encoded string
let pngToHtml fileName cssStyle =
sprintf """<img src="data:image/png;base64,%s" style="%s"/>""" (fileName |> fileToBase64String) cssStyle
Then I can do things like
// Generates an image file in the code
batch.saveImage("mnist-samples.png")
// Embeds the generated image in the fsdocs output
(*** hide ***)
pngToHtml "mnist-samples.png" "width:25%;height:auto;image-rendering:pixelated"
(*** include-it-raw ***)