Skip to content

Commit f26ed78

Browse files
committed
explicit cmarkit
1 parent 4c66007 commit f26ed78

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

tools/src/tools.ml

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -728,22 +728,23 @@ module FormatCodeblocks = struct
728728
end
729729
let formatRescriptCodeBlocks content ~transformAssertEqual ~displayFilename
730730
~addError ~markdownBlockStartLine =
731-
let open Cmarkit in
732731
(* Detect ReScript code blocks. *)
733732
let hadCodeBlocks = ref false in
734733
let block _m = function
735-
| Block.Code_block (codeBlock, meta) -> (
736-
match Block.Code_block.info_string codeBlock with
734+
| Cmarkit.Block.Code_block (codeBlock, meta) -> (
735+
match Cmarkit.Block.Code_block.info_string codeBlock with
737736
| Some ((("rescript" | "res"), _) as info_string) ->
738737
hadCodeBlocks := true;
739738

740739
let currentLine =
741-
meta |> Meta.textloc |> Textloc.first_line |> fst |> Int.add 1
740+
meta |> Cmarkit.Meta.textloc |> Cmarkit.Textloc.first_line |> fst
742741
in
743-
let layout = Block.Code_block.layout codeBlock in
744-
let code = Block.Code_block.code codeBlock in
742+
(* Account for 0-based line numbers *)
743+
let currentLine = currentLine + 1 in
744+
let layout = Cmarkit.Block.Code_block.layout codeBlock in
745+
let code = Cmarkit.Block.Code_block.code codeBlock in
745746
let codeText =
746-
code |> List.map Block_line.to_string |> String.concat "\n"
747+
code |> List.map Cmarkit.Block_line.to_string |> String.concat "\n"
747748
in
748749

749750
let n = List.length code in
@@ -773,19 +774,21 @@ module FormatCodeblocks = struct
773774
else parsetree
774775
in
775776
Res_printer.print_implementation parsetree ~comments
776-
|> String.trim |> Block_line.list_of_string
777+
|> String.trim |> Cmarkit.Block_line.list_of_string
777778
in
778779

779780
let mappedCodeBlock =
780-
Block.Code_block.make ~layout ~info_string formattedCode
781+
Cmarkit.Block.Code_block.make ~layout ~info_string formattedCode
781782
in
782-
Mapper.ret (Block.Code_block (mappedCodeBlock, meta))
783-
| _ -> Mapper.default)
784-
| _ -> Mapper.default
783+
Cmarkit.Mapper.ret (Cmarkit.Block.Code_block (mappedCodeBlock, meta))
784+
| _ -> Cmarkit.Mapper.default)
785+
| _ -> Cmarkit.Mapper.default
785786
in
786-
let mapper = Mapper.make ~block () in
787+
let mapper = Cmarkit.Mapper.make ~block () in
787788
let newContent =
788-
content |> Doc.of_string ~locs:true |> Mapper.map_doc mapper
789+
content
790+
|> Cmarkit.Doc.of_string ~locs:true
791+
|> Cmarkit.Mapper.map_doc mapper
789792
|> Cmarkit_commonmark.of_doc
790793
in
791794
(newContent, !hadCodeBlocks)

0 commit comments

Comments
 (0)