aboutsummaryrefslogtreecommitdiff
path: root/editor/actions
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@dailly.me>2021-11-25 08:59:29 +0100
committerSébastien Dailly <sebastien@dailly.me>2022-02-07 16:43:33 +0100
commitf30e3eeb06bb932e6735868d404926cc7a9cd8aa (patch)
tree0bf47bf5c81c61c279bc82b969f70a080c3ae45f /editor/actions
parent536ca039cbae6025ae210231cdc149430be09b4e (diff)
List all the cases in the Markdown pattern
Diffstat (limited to 'editor/actions')
-rwxr-xr-xeditor/actions/of_markdown.ml25
1 files changed, 21 insertions, 4 deletions
diff --git a/editor/actions/of_markdown.ml b/editor/actions/of_markdown.ml
index 88f7c00..951feed 100755
--- a/editor/actions/of_markdown.ml
+++ b/editor/actions/of_markdown.ml
@@ -154,7 +154,7 @@ module FromMarkdown = struct
(* The whole list node is declared as ordered or bullet depending of
the type given by the markdown.
- Each element insiide the list is transformed as a list_item.
+ Each element inside the list is transformed as a list_item.
The list_item node can itself contains other blocks (recursively) *)
let nodes = List.map elements
@@ -206,9 +206,26 @@ module FromMarkdown = struct
(Js.null) in
Some node
- | Code_block(_, _, _)
- (* TODO *)
- -> None
+ | Code_block(attrs, content, format) ->
+ ignore attrs;
+
+ (* The language format is ignored (I do not provide syntaxic
+ coloration) *)
+ ignore format;
+
+ (* TODO Check if this work *)
+ let nodes = Js.array
+ [| view##.state##.schema##text
+ (Jstr.of_string content)
+ (Js.null)
+ |] in
+ let fragment = PM.Model.Fragment.from_array pm nodes in
+ let node = view##.state##.schema##node
+ (Jstr.v "code_block")
+ (Js.null)
+ (Js.some fragment)
+ (Js.null) in
+ Some node
| Html_block(_, _)
| Definition_list(_, _)
->