@@ -728,22 +728,23 @@ module FormatCodeblocks = struct
728
728
end
729
729
let formatRescriptCodeBlocks content ~transformAssertEqual ~displayFilename
730
730
~addError ~markdownBlockStartLine =
731
- let open Cmarkit in
732
731
(* Detect ReScript code blocks. *)
733
732
let hadCodeBlocks = ref false in
734
733
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
737
736
| Some ((("rescript" | "res" ), _ ) as info_string ) ->
738
737
hadCodeBlocks := true ;
739
738
740
739
let currentLine =
741
- meta |> Meta. textloc |> Textloc. first_line |> fst |> Int. add 1
740
+ meta |> Cmarkit. Meta. textloc |> Cmarkit. Textloc. first_line |> fst
742
741
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
745
746
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 "
747
748
in
748
749
749
750
let n = List. length code in
@@ -773,19 +774,21 @@ module FormatCodeblocks = struct
773
774
else parsetree
774
775
in
775
776
Res_printer. print_implementation parsetree ~comments
776
- |> String. trim |> Block_line. list_of_string
777
+ |> String. trim |> Cmarkit. Block_line. list_of_string
777
778
in
778
779
779
780
let mappedCodeBlock =
780
- Block.Code_block. make ~layout ~info_string formattedCode
781
+ Cmarkit. Block.Code_block. make ~layout ~info_string formattedCode
781
782
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
785
786
in
786
- let mapper = Mapper. make ~block () in
787
+ let mapper = Cmarkit. Mapper. make ~block () in
787
788
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
789
792
|> Cmarkit_commonmark. of_doc
790
793
in
791
794
(newContent, ! hadCodeBlocks)
0 commit comments