From f30e3eeb06bb932e6735868d404926cc7a9cd8aa Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Thu, 25 Nov 2021 08:59:29 +0100 Subject: List all the cases in the Markdown pattern --- editor/actions/of_markdown.ml | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'editor/actions') 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(_, _) -> -- cgit v1.2.3