Open
Description
After #97 and #525 have been merged we can provider basic syntax highlight when hovering.
Current state
Apparently vscode does not detect ```res example
as rescript syntax. In markdown highlighting works.
Proposal
Convert ```res example
to rescript
. This can be done on the client side `client/src/extension.ts`, but I'm more +1 to do it in analysis bin as it wouldn't affect other clients.
As the return is markdown we could create sections using the word after ```res
?
From:
```res example
To:
## Example\n```rescript
Example:
From:
Constructs a RegExp object (Js.Re.t) from a `string`.
Regex literals `%re("/.../")` should generally be preferred, but `fromString`
is useful when you need to dynamically construct a regex using strings,
exactly like when you do so in JavaScript.
```res example
let firstReScriptFileExtension = (filename, content) => {
let result = Js.Re.fromString(filename ++ "\.(res|resi)")->Js.Re.exec_(content)
switch result {
| Some(r) => Js.Nullable.toOption(Js.Re.captures(r)[1])
| None => None
}
}
// outputs "res"
firstReScriptFileExtension("School", "School.res School.resi Main.js School.bs.js")
```
To:
Constructs a RegExp object (Js.Re.t) from a `string`.
Regex literals `%re("/.../")` should generally be preferred, but `fromString`
is useful when you need to dynamically construct a regex using strings,
exactly like when you do so in JavaScript.
## Example
```rescript
let firstReScriptFileExtension = (filename, content) => {
let result = Js.Re.fromString(filename ++ "\.(res|resi)")->Js.Re.exec_(content)
switch result {
| Some(r) => Js.Nullable.toOption(Js.Re.captures(r)[1])
| None => None
}
}
// outputs "res"
firstReScriptFileExtension("School", "School.res School.resi Main.js School.bs.js")
```
Below an example after convert res
to rescript
. Note: indentation at the beginning of the line are preserved, we must remove them.
Metadata
Metadata
Assignees
Labels
No labels