File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change 1
1
open Cmdliner
2
2
3
+ let raw t =
4
+ let cell = Notebook_t. {
5
+ cell_type = `Raw ;
6
+ metadata = {
7
+ collapsed = None ;
8
+ scrolled = None ;
9
+ };
10
+ source = String. concat " \n " t;
11
+ outputs = None ;
12
+ execution_count = None ;
13
+ } in
14
+ cell
15
+
3
16
let txt t =
4
17
let cell = Notebook_t. {
5
18
cell_type = `Markdown ;
@@ -52,6 +65,12 @@ let run _setup syntax file =
52
65
let rec collapse_text = function
53
66
| Mdx. Text x :: Mdx. Text y :: xs ->
54
67
collapse_text (Mdx. Text (x ^ " \n " ^ y) :: xs)
68
+ | Mdx. Section _ as s :: Mdx. Text y :: xs ->
69
+ let s = Mdx. to_string [s] in
70
+ collapse_text (Mdx. Text (s ^ " \n " ^ y) :: xs)
71
+ | Mdx. Section _ as s :: xs ->
72
+ let s = Mdx. to_string [s] in
73
+ collapse_text (Mdx. Text s :: xs)
55
74
| x ::ys -> x :: collapse_text ys
56
75
| [] -> []
57
76
in
@@ -64,7 +83,9 @@ let run _setup syntax file =
64
83
| Mdx. Block {value =Toplevel xs ; _} ->
65
84
let newcells = List. rev_map toplevel xs in
66
85
cells := newcells @ ! cells
67
- | _ -> ()
86
+ | Mdx. Block {value =Raw ; contents; _} ->
87
+ cells := (raw contents) :: ! cells
88
+ | x -> failwith (Printf. sprintf " internal error, cannot handle: %s" (Mdx. to_string [x]))
68
89
) (collapse_text items);
69
90
" OK"
70
91
);
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ type cell_metadata = {
27
27
type cell_type = [
28
28
| Code <json name="code">
29
29
| Markdown <json name="markdown">
30
+ | Raw <json name="raw">
30
31
]
31
32
32
33
type output_type = [
@@ -53,4 +54,4 @@ type notebook = {
53
54
nbformat: int;
54
55
nbformat_minor: int;
55
56
cells: cell list
56
- }
57
+ }
You can’t perform that action at this time.
0 commit comments