Created
September 9, 2020 19:46
-
-
Save craigfe/afe8530d0c4657558540d4b31e17eef1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/bin/dune b/bin/dune | |
index b96f1a0..2e2b973 100644 | |
--- a/bin/dune | |
+++ b/bin/dune | |
@@ -8,7 +8,7 @@ | |
(public_name ocaml-mdx) | |
(package mdx) | |
(modules :standard \ cli) | |
- (libraries cli mdx)) | |
+ (libraries cli mdx fmt)) | |
(rule | |
(targets notebook_j.ml notebook_j.mli) | |
diff --git a/bin/jupyter.ml b/bin/jupyter.ml | |
index 5368255..4147c15 100644 | |
--- a/bin/jupyter.ml | |
+++ b/bin/jupyter.ml | |
@@ -29,13 +29,13 @@ let txt t = | |
let execution_count = ref 1 | |
-let ocaml contents = | |
+let ocaml source = | |
let cell = | |
Notebook_t. | |
{ | |
cell_type = `Code; | |
metadata = { collapsed = None; scrolled = None }; | |
- source = String.concat "\n" contents; | |
+ source; | |
outputs = Some []; | |
execution_count = Some !execution_count; | |
} | |
@@ -88,6 +88,11 @@ let run _setup (`Syntax syntax) (`File file) = | |
| Mdx.Block { value = Toplevel { env = User_defined _; _ }; _ } -> | |
failwith "internal error, cannot handle user defined environments" | |
| Mdx.Block { value = OCaml _; contents; _ } -> | |
+ cells := ocaml (String.concat "\n" contents) :: !cells | |
+ | Mdx.Block | |
+ ( { value = Include { file_kind = Mdx.Block.Fk_ocaml _; _ }; _ } | |
+ as b ) -> | |
+ let contents = Fmt.to_to_string Mdx.Block.pp_contents b in | |
cells := ocaml contents :: !cells | |
| Mdx.Block { value = Toplevel _; contents; file; column; line; _ } -> | |
let blocks = |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment