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 1
1
/**
2
2
This is the first docstring with unformatted ReScript code.
3
3
4
- ```rescript
4
+ ```res example
5
5
let badly_formatted=(x,y)=>{
6
6
let result=x+y
7
7
if result>0{Console.log("positive")}else{Console.log("negative")}
@@ -24,7 +24,7 @@ module Nested = {
24
24
25
25
But if I add another line here it should be fine.
26
26
27
- ```rescript
27
+ ```res info
28
28
module UserService={
29
29
let validate=user => user.age>=18 && user.name !== ""
30
30
let getName = user=>user.name
Original file line number Diff line number Diff line change 1
1
/**
2
2
This is the first docstring with unformatted ReScript code.
3
3
4
- ```rescript
4
+ ```res example
5
5
let badly_formatted = (x, y) => {
6
6
let result = x + y
7
7
if result > 0 {
@@ -28,7 +28,7 @@ module Nested = {
28
28
29
29
But if I add another line here it should be fine.
30
30
31
- ```rescript
31
+ ```res info
32
32
module UserService = {
33
33
let validate = user => user.age >= 18 && user.name !== ""
34
34
let getName = user => user.name
Original file line number Diff line number Diff line change @@ -726,14 +726,24 @@ module FormatCodeblocks = struct
726
726
in
727
727
mapper.structure mapper ast
728
728
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
+
729
739
let formatRescriptCodeBlocks content ~transformAssertEqual ~displayFilename
730
740
~addError ~markdownBlockStartLine =
731
741
(* Detect ReScript code blocks. *)
732
742
let hadCodeBlocks = ref false in
733
743
let block _m = function
734
744
| Cmarkit.Block. Code_block (codeBlock , meta ) -> (
735
745
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 ->
737
747
hadCodeBlocks := true ;
738
748
739
749
let currentLine =
You can’t perform that action at this time.
0 commit comments