File tree Expand file tree Collapse file tree 3 files changed +15
-5
lines changed
Expand file tree Collapse file tree 3 files changed +15
-5
lines changed Original file line number Diff line number Diff line change 11/**
22This is the first docstring with unformatted ReScript code.
33
4- ```rescript
4+ ```res example
55let badly_formatted=(x,y)=>{
66let result=x+y
77if result>0{Console.log("positive")}else{Console.log("negative")}
@@ -24,7 +24,7 @@ module Nested = {
2424
2525 But if I add another line here it should be fine.
2626
27- ```rescript
27+ ```res info
2828 module UserService={
2929 let validate=user => user.age>=18 && user.name !== ""
3030 let getName = user=>user.name
Original file line number Diff line number Diff line change 11/**
22This is the first docstring with unformatted ReScript code.
33
4- ```rescript
4+ ```res example
55let badly_formatted = (x, y) => {
66 let result = x + y
77 if result > 0 {
@@ -28,7 +28,7 @@ module Nested = {
2828
2929 But if I add another line here it should be fine.
3030
31- ```rescript
31+ ```res info
3232 module UserService = {
3333 let validate = user => user.age >= 18 && user.name !== ""
3434 let getName = user => user.name
Original file line number Diff line number Diff line change @@ -726,14 +726,24 @@ module FormatCodeblocks = struct
726726 in
727727 mapper.structure mapper ast
728728 end
729+
730+ let isResLang lang =
731+ match String. lowercase_ascii lang with
732+ | "res" | "rescript" | "resi" -> true
733+ | lang ->
734+ (* Cover ```res example, and similar *)
735+ String. starts_with ~prefix: " res " lang
736+ || String. starts_with ~prefix: " rescript " lang
737+ || String. starts_with ~prefix: " resi " lang
738+
729739 let formatRescriptCodeBlocks content ~transformAssertEqual ~displayFilename
730740 ~addError ~markdownBlockStartLine =
731741 (* Detect ReScript code blocks. *)
732742 let hadCodeBlocks = ref false in
733743 let block _m = function
734744 | Cmarkit.Block. Code_block (codeBlock , meta ) -> (
735745 match Cmarkit.Block.Code_block. info_string codeBlock with
736- | Some ((( "rescript" | "res" ) , _ ) as info_string ) ->
746+ | Some ((lang , _ ) as info_string ) when isResLang lang ->
737747 hadCodeBlocks := true ;
738748
739749 let currentLine =
You can’t perform that action at this time.
0 commit comments