-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Added support for ReScript #3435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
RunDevelopment
merged 20 commits into
PrismJS:master
from
vmarcosp:feat/rescript-support
Apr 15, 2022
Merged
Changes from 3 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
5e589e4
add support for ReScript
vmarcosp f2bf41c
adding rescript to components.json
vmarcosp 1a8cc15
fix formatter issues
vmarcosp ee89cef
improving rescript examples
vmarcosp 3302d43
improving rescript examples
vmarcosp 9a035b6
fix requested changes
vmarcosp 16afdd4
fix tests and added aliases to rescript
vmarcosp bb8c35a
improving rescript comment capturing
vmarcosp db25eff
updating rescript feature tests
vmarcosp 9a06023
fix rescript examples
vmarcosp ea19693
adding greedy field to rescript strings
vmarcosp 14f0ee0
removing unused vars
vmarcosp 4dfbbef
fix requested changes
vmarcosp 53a7c98
removing unused groups
vmarcosp 9415642
adding more tests for rescript
vmarcosp eefd85b
improving rescript chart support
vmarcosp 18387cb
updating all tests
vmarcosp 2f312b4
fix rescript operators and keyword test
vmarcosp de5ce3c
updating rescript tests
vmarcosp 3bd9b37
updating build
vmarcosp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| var operator = /\.{3}|:[:=]|\|>|->|=(?:==?|>)?|<=?|>=?|[|^?'#!~`]|[+\-*\/]\.?|\b(?:asr|land|lor|lsl|lsr|lxor|mod)\b/; | ||
RunDevelopment marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| var className = /(\b[A-Z]\w*)|(@[a-z.]*)|#[A-Za-z]\w*|#\d/; | ||
| var number = /(?:\b0x(?:[\da-f]+(?:\.[\da-f]*)?|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)[ful]{0,4}/i; | ||
| var keyword = /\b(?:and|as|assert|begin|bool|class|constraint|do|done|downto|else|end|exception|external|float|for|fun|function|if|in|include|inherit|initializer|int|lazy|let|method|module|mutable|new|nonrec|object|of|open|or|private|rec|string|switch|then|to|try|type|val|virtual|when|while|with)\b/; | ||
|
|
||
| Prism.languages.rescript = { | ||
| 'comment': { | ||
| pattern: /\/\/(?:[^\r\n\\]|\\(?:\r\n?|\n|(?![\r\n])))*|\/\*[\s\S]*?(?:\*\/|$)/, | ||
| greedy: true | ||
| }, | ||
| 'class-name': className, | ||
| 'function': { | ||
| pattern: /[a-zA-Z]\w*(?=\()|(\.)[a-z]\w*/, | ||
| lookbehind: true, | ||
| }, | ||
RunDevelopment marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 'number': /(?:\b0x(?:[\da-f]+(?:\.[\da-f]*)?|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)[ful]{0,4}/i, | ||
| 'string': { | ||
RunDevelopment marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| pattern: /("(?:\\(?:\r\n|[\s\S])|[^\\\r\n"])*")|(`(?:\\(?:\r\n|[\s\S])|[^\\\r\n"])*`)/, | ||
| greedy: true, | ||
| inside: { | ||
| 'tag': { | ||
| pattern: /\$\{.*\}/, | ||
| inside: { | ||
| 'class-name': /[A-Z]\w*/g, | ||
| 'function': /[a-z]\w*/g, | ||
| 'punctuation': /\./g, | ||
| 'operator': operator, | ||
| 'number': number, | ||
| 'keyword': keyword | ||
| } | ||
| }, | ||
| } | ||
| }, | ||
| 'attr-value': /[A-Za-z]\w*(?==)/, | ||
| 'constant': new RegExp('(?<=type\\s)[a-z]\\w*'), | ||
RunDevelopment marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 'tag': { | ||
| pattern: new RegExp('((?<=<)[a-z]\\w*)|((?:<\\/)[a-z]\\w*)'), | ||
RunDevelopment marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| inside: { | ||
| 'operator': /<|>|\//, | ||
| }, | ||
| }, | ||
| 'keyword': keyword, | ||
| 'operator': operator | ||
| }; | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| <h2>Comments</h2> | ||
| <pre><code>/* This is a comment */ | ||
| // Another comment | ||
| </code></pre> | ||
|
|
||
| <h2>Strings and characters</h2> | ||
| <pre><code>let name = "Alonzo Church" | ||
| let message = `Hello ${name}` | ||
| let message2 = `Hello ${person.name}` | ||
| let result = `Testing => ${Module.Another.value}` | ||
| </code></pre> | ||
|
|
||
| <h2>Type declarations & Functions</h2> | ||
| <pre><code>type role = | Admin | Editor | Viewer | ||
| type numeric = #1 | #2 | #3 | ||
| type normal = #Poly | #Variant | ||
| type myPolyVar = [ #"poly-variant" | #"test-chars" ] | ||
|
|
||
| type person = { | ||
| name: string, | ||
| age: int, | ||
| role: role | ||
| } | ||
|
|
||
| let sum = (a, b) => a + b | ||
| let sum = (a:int, b: int) => a + b | ||
| </code></pre> | ||
|
|
||
| <h2>JSX & Components</h2> | ||
| <pre> | ||
RunDevelopment marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| <code> | ||
| module Button = { | ||
| @react.component | ||
| let make = (~count: int) => { | ||
| let times = switch count { | ||
| | 1 => "once" | ||
| | 2 => "twice" | ||
| | n => Belt.Int.toString(n) ++ " times" | ||
| } | ||
| let msg = "Click me " ++ times | ||
|
|
||
| <button onClick={Js.log}>{msg->React.string}</button>; | ||
| } | ||
| } | ||
|
|
||
| @react.component | ||
| let make = () => <MyModule.Button count=1 /> | ||
| </code> | ||
| </pre> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.