@exercism/highlightjs-racket 0.0.0-stage → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +57 -0
- package/README.md +72 -2
- package/bun.lock +150 -0
- package/package.json +37 -4
- package/src/racket.d.ts +2 -0
- package/src/racket.js +1 -0
- package/src/racket.ts +490 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Exercism
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
The grammar in src/racket.ts started as a fork of the Scheme grammar in
|
|
26
|
+
highlight.js (https://github.com/highlightjs/highlight.js), which is under the
|
|
27
|
+
following licence:
|
|
28
|
+
|
|
29
|
+
BSD 3-Clause License
|
|
30
|
+
|
|
31
|
+
Copyright (c) 2006, Ivan Sagalaev.
|
|
32
|
+
All rights reserved.
|
|
33
|
+
|
|
34
|
+
Redistribution and use in source and binary forms, with or without
|
|
35
|
+
modification, are permitted provided that the following conditions are met:
|
|
36
|
+
|
|
37
|
+
* Redistributions of source code must retain the above copyright notice, this
|
|
38
|
+
list of conditions and the following disclaimer.
|
|
39
|
+
|
|
40
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
|
41
|
+
this list of conditions and the following disclaimer in the documentation
|
|
42
|
+
and/or other materials provided with the distribution.
|
|
43
|
+
|
|
44
|
+
* Neither the name of the copyright holder nor the names of its
|
|
45
|
+
contributors may be used to endorse or promote products derived from
|
|
46
|
+
this software without specific prior written permission.
|
|
47
|
+
|
|
48
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
49
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
50
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
51
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
52
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
53
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
54
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
55
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
56
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
57
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,73 @@
|
|
|
1
|
-
#
|
|
1
|
+
# highlightjs-racket · [](https://github.com/exercism/highlightjs-racket/blob/main/LICENSE) [](https://www.npmjs.com/package/@exercism/highlightjs-racket)
|
|
2
2
|
|
|
3
|
-
This
|
|
3
|
+
This repository contains a highlight.js plugin for the [Racket language](https://racket-lang.org/).
|
|
4
|
+
|
|
5
|
+
It highlights `#lang` lines, Racket's syntactic forms (such as `define/contract`, `struct`, `match`, `λ` and every `for/` loop), `#:keyword` arguments, `#hash`, `#rx` and `#px` literals, characters such as `#\space`, square-bracket clauses, and `#| |#` and `#;` comments.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
To install the package, run:
|
|
10
|
+
|
|
11
|
+
```shell
|
|
12
|
+
npm install @exercism/highlightjs-racket
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Then register the language under the name `racket`:
|
|
16
|
+
|
|
17
|
+
```javascript
|
|
18
|
+
import hljs from "highlight.js";
|
|
19
|
+
import hljsDefineRacket from "@exercism/highlightjs-racket";
|
|
20
|
+
|
|
21
|
+
hljs.registerLanguage("racket", hljsDefineRacket);
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
The grammar uses no regex lookbehind, so it loads in every browser that highlight.js supports.
|
|
25
|
+
|
|
26
|
+
## Tests
|
|
27
|
+
|
|
28
|
+
To run the tests, run:
|
|
29
|
+
|
|
30
|
+
```shell
|
|
31
|
+
bun test
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Each file in `test/markup` is some Racket code, and the `.expected` file next to it is the HTML that highlight.js should produce from it.
|
|
35
|
+
The `solution-*` files are example solutions from the [Exercism Racket track](https://github.com/exercism/racket).
|
|
36
|
+
|
|
37
|
+
To check the grammar against every example solution in a checkout of the Racket track, run:
|
|
38
|
+
|
|
39
|
+
```shell
|
|
40
|
+
bun bin/render-solutions path/to/racket path/to/output-dir
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
It reports any solution where highlighting changed the text or hit an illegal match.
|
|
44
|
+
It lists the words given each highlight.js scope, so a word with the wrong colour stands out, and writes each solution's HTML to the output directory.
|
|
45
|
+
|
|
46
|
+
## Publish on NPM
|
|
47
|
+
|
|
48
|
+
To publish the package, run:
|
|
49
|
+
|
|
50
|
+
```shell
|
|
51
|
+
bun publish
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Local development
|
|
55
|
+
|
|
56
|
+
First, install the dependencies:
|
|
57
|
+
|
|
58
|
+
```shell
|
|
59
|
+
bun install
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Then run:
|
|
63
|
+
|
|
64
|
+
```shell
|
|
65
|
+
bun dev
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
This will start a [Vite dev server](https://vite.dev/) that shows some highlighted Racket code.
|
|
69
|
+
|
|
70
|
+
## Credits
|
|
71
|
+
|
|
72
|
+
This grammar was originally forked from the [Scheme grammar in highlight.js](https://github.com/highlightjs/highlight.js/blob/main/src/languages/scheme.js), written by JP Verkamp with contributions from Ivan Sagalaev.
|
|
73
|
+
highlight.js is under the BSD 3-Clause licence, and its copyright notice is kept in [LICENSE](LICENSE) and at the top of `src/racket.ts`.
|
package/bun.lock
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
{
|
|
2
|
+
"lockfileVersion": 1,
|
|
3
|
+
"workspaces": {
|
|
4
|
+
"": {
|
|
5
|
+
"name": "@exercism/highlightjs-racket",
|
|
6
|
+
"devDependencies": {
|
|
7
|
+
"@types/bun": "latest",
|
|
8
|
+
"@types/highlight.js": "^10.1.0",
|
|
9
|
+
"highlight.js": "^11.10.0",
|
|
10
|
+
"vite": "^5.4.11",
|
|
11
|
+
},
|
|
12
|
+
"peerDependencies": {
|
|
13
|
+
"typescript": "^5.4.5",
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
"packages": {
|
|
18
|
+
"@esbuild/aix-ppc64": ["@esbuild/aix-ppc64@0.21.5", "", { "os": "aix", "cpu": "ppc64" }, "sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ=="],
|
|
19
|
+
|
|
20
|
+
"@esbuild/android-arm": ["@esbuild/android-arm@0.21.5", "", { "os": "android", "cpu": "arm" }, "sha512-vCPvzSjpPHEi1siZdlvAlsPxXl7WbOVUBBAowWug4rJHb68Ox8KualB+1ocNvT5fjv6wpkX6o/iEpbDrf68zcg=="],
|
|
21
|
+
|
|
22
|
+
"@esbuild/android-arm64": ["@esbuild/android-arm64@0.21.5", "", { "os": "android", "cpu": "arm64" }, "sha512-c0uX9VAUBQ7dTDCjq+wdyGLowMdtR/GoC2U5IYk/7D1H1JYC0qseD7+11iMP2mRLN9RcCMRcjC4YMclCzGwS/A=="],
|
|
23
|
+
|
|
24
|
+
"@esbuild/android-x64": ["@esbuild/android-x64@0.21.5", "", { "os": "android", "cpu": "x64" }, "sha512-D7aPRUUNHRBwHxzxRvp856rjUHRFW1SdQATKXH2hqA0kAZb1hKmi02OpYRacl0TxIGz/ZmXWlbZgjwWYaCakTA=="],
|
|
25
|
+
|
|
26
|
+
"@esbuild/darwin-arm64": ["@esbuild/darwin-arm64@0.21.5", "", { "os": "darwin", "cpu": "arm64" }, "sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ=="],
|
|
27
|
+
|
|
28
|
+
"@esbuild/darwin-x64": ["@esbuild/darwin-x64@0.21.5", "", { "os": "darwin", "cpu": "x64" }, "sha512-se/JjF8NlmKVG4kNIuyWMV/22ZaerB+qaSi5MdrXtd6R08kvs2qCN4C09miupktDitvh8jRFflwGFBQcxZRjbw=="],
|
|
29
|
+
|
|
30
|
+
"@esbuild/freebsd-arm64": ["@esbuild/freebsd-arm64@0.21.5", "", { "os": "freebsd", "cpu": "arm64" }, "sha512-5JcRxxRDUJLX8JXp/wcBCy3pENnCgBR9bN6JsY4OmhfUtIHe3ZW0mawA7+RDAcMLrMIZaf03NlQiX9DGyB8h4g=="],
|
|
31
|
+
|
|
32
|
+
"@esbuild/freebsd-x64": ["@esbuild/freebsd-x64@0.21.5", "", { "os": "freebsd", "cpu": "x64" }, "sha512-J95kNBj1zkbMXtHVH29bBriQygMXqoVQOQYA+ISs0/2l3T9/kj42ow2mpqerRBxDJnmkUDCaQT/dfNXWX/ZZCQ=="],
|
|
33
|
+
|
|
34
|
+
"@esbuild/linux-arm": ["@esbuild/linux-arm@0.21.5", "", { "os": "linux", "cpu": "arm" }, "sha512-bPb5AHZtbeNGjCKVZ9UGqGwo8EUu4cLq68E95A53KlxAPRmUyYv2D6F0uUI65XisGOL1hBP5mTronbgo+0bFcA=="],
|
|
35
|
+
|
|
36
|
+
"@esbuild/linux-arm64": ["@esbuild/linux-arm64@0.21.5", "", { "os": "linux", "cpu": "arm64" }, "sha512-ibKvmyYzKsBeX8d8I7MH/TMfWDXBF3db4qM6sy+7re0YXya+K1cem3on9XgdT2EQGMu4hQyZhan7TeQ8XkGp4Q=="],
|
|
37
|
+
|
|
38
|
+
"@esbuild/linux-ia32": ["@esbuild/linux-ia32@0.21.5", "", { "os": "linux", "cpu": "ia32" }, "sha512-YvjXDqLRqPDl2dvRODYmmhz4rPeVKYvppfGYKSNGdyZkA01046pLWyRKKI3ax8fbJoK5QbxblURkwK/MWY18Tg=="],
|
|
39
|
+
|
|
40
|
+
"@esbuild/linux-loong64": ["@esbuild/linux-loong64@0.21.5", "", { "os": "linux", "cpu": "none" }, "sha512-uHf1BmMG8qEvzdrzAqg2SIG/02+4/DHB6a9Kbya0XDvwDEKCoC8ZRWI5JJvNdUjtciBGFQ5PuBlpEOXQj+JQSg=="],
|
|
41
|
+
|
|
42
|
+
"@esbuild/linux-mips64el": ["@esbuild/linux-mips64el@0.21.5", "", { "os": "linux", "cpu": "none" }, "sha512-IajOmO+KJK23bj52dFSNCMsz1QP1DqM6cwLUv3W1QwyxkyIWecfafnI555fvSGqEKwjMXVLokcV5ygHW5b3Jbg=="],
|
|
43
|
+
|
|
44
|
+
"@esbuild/linux-ppc64": ["@esbuild/linux-ppc64@0.21.5", "", { "os": "linux", "cpu": "ppc64" }, "sha512-1hHV/Z4OEfMwpLO8rp7CvlhBDnjsC3CttJXIhBi+5Aj5r+MBvy4egg7wCbe//hSsT+RvDAG7s81tAvpL2XAE4w=="],
|
|
45
|
+
|
|
46
|
+
"@esbuild/linux-riscv64": ["@esbuild/linux-riscv64@0.21.5", "", { "os": "linux", "cpu": "none" }, "sha512-2HdXDMd9GMgTGrPWnJzP2ALSokE/0O5HhTUvWIbD3YdjME8JwvSCnNGBnTThKGEB91OZhzrJ4qIIxk/SBmyDDA=="],
|
|
47
|
+
|
|
48
|
+
"@esbuild/linux-s390x": ["@esbuild/linux-s390x@0.21.5", "", { "os": "linux", "cpu": "s390x" }, "sha512-zus5sxzqBJD3eXxwvjN1yQkRepANgxE9lgOW2qLnmr8ikMTphkjgXu1HR01K4FJg8h1kEEDAqDcZQtbrRnB41A=="],
|
|
49
|
+
|
|
50
|
+
"@esbuild/linux-x64": ["@esbuild/linux-x64@0.21.5", "", { "os": "linux", "cpu": "x64" }, "sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ=="],
|
|
51
|
+
|
|
52
|
+
"@esbuild/netbsd-x64": ["@esbuild/netbsd-x64@0.21.5", "", { "os": "none", "cpu": "x64" }, "sha512-Woi2MXzXjMULccIwMnLciyZH4nCIMpWQAs049KEeMvOcNADVxo0UBIQPfSmxB3CWKedngg7sWZdLvLczpe0tLg=="],
|
|
53
|
+
|
|
54
|
+
"@esbuild/openbsd-x64": ["@esbuild/openbsd-x64@0.21.5", "", { "os": "openbsd", "cpu": "x64" }, "sha512-HLNNw99xsvx12lFBUwoT8EVCsSvRNDVxNpjZ7bPn947b8gJPzeHWyNVhFsaerc0n3TsbOINvRP2byTZ5LKezow=="],
|
|
55
|
+
|
|
56
|
+
"@esbuild/sunos-x64": ["@esbuild/sunos-x64@0.21.5", "", { "os": "sunos", "cpu": "x64" }, "sha512-6+gjmFpfy0BHU5Tpptkuh8+uw3mnrvgs+dSPQXQOv3ekbordwnzTVEb4qnIvQcYXq6gzkyTnoZ9dZG+D4garKg=="],
|
|
57
|
+
|
|
58
|
+
"@esbuild/win32-arm64": ["@esbuild/win32-arm64@0.21.5", "", { "os": "win32", "cpu": "arm64" }, "sha512-Z0gOTd75VvXqyq7nsl93zwahcTROgqvuAcYDUr+vOv8uHhNSKROyU961kgtCD1e95IqPKSQKH7tBTslnS3tA8A=="],
|
|
59
|
+
|
|
60
|
+
"@esbuild/win32-ia32": ["@esbuild/win32-ia32@0.21.5", "", { "os": "win32", "cpu": "ia32" }, "sha512-SWXFF1CL2RVNMaVs+BBClwtfZSvDgtL//G/smwAc5oVK/UPu2Gu9tIaRgFmYFFKrmg3SyAjSrElf0TiJ1v8fYA=="],
|
|
61
|
+
|
|
62
|
+
"@esbuild/win32-x64": ["@esbuild/win32-x64@0.21.5", "", { "os": "win32", "cpu": "x64" }, "sha512-tQd/1efJuzPC6rCFwEvLtci/xNFcTZknmXs98FYDfGE4wP9ClFV98nyKrzJKVPMhdDnjzLhdUyMX4PsQAPjwIw=="],
|
|
63
|
+
|
|
64
|
+
"@rollup/rollup-android-arm-eabi": ["@rollup/rollup-android-arm-eabi@4.68.9", "", { "os": "android", "cpu": "arm" }, "sha512-Z1hkXtnYKf3sHDD8F2Ll7g9ZGwgAdVNThyz3KiTGSWkjKgYPz/a3TEPoR7ZXE9YlLvbpaO8g+3zisGbU40WQsg=="],
|
|
65
|
+
|
|
66
|
+
"@rollup/rollup-android-arm64": ["@rollup/rollup-android-arm64@4.68.9", "", { "os": "android", "cpu": "arm64" }, "sha512-9FG3WZfMVLlbYB8Vyy2w2t50IMbGQ1dWfiCvkacTtXAmXxkHDkxCdomxW6869YEMD1gTsgDF5i9RXASw/8iaZw=="],
|
|
67
|
+
|
|
68
|
+
"@rollup/rollup-android-x64": ["@rollup/rollup-android-x64@4.68.9", "", { "os": "android", "cpu": "x64" }, "sha512-nsxur8e5bfr8YdUwupKED/XJD6X02FVIQkv2zDVJQkesfI0/Lt4vMDFjlWNqWgHbZ38nt8xhk/gbJWdzVtWCfA=="],
|
|
69
|
+
|
|
70
|
+
"@rollup/rollup-darwin-arm64": ["@rollup/rollup-darwin-arm64@4.68.9", "", { "os": "darwin", "cpu": "arm64" }, "sha512-tkqdvGDK6pmcd419n4zHSFkJcnEIuluYKZArnzWq+O02RYe5jymtAF/c92VP6/JR9nawrV6+LC23GhSPeNZUmA=="],
|
|
71
|
+
|
|
72
|
+
"@rollup/rollup-darwin-x64": ["@rollup/rollup-darwin-x64@4.68.9", "", { "os": "darwin", "cpu": "x64" }, "sha512-1vWrRYmFBNs1UKMogcvl5Vg9mdOA3yQgGQGJrQaxHgnR2Qj57L5QiAJBKk1Ednwanxa6dzxGvBaw4I+Evuxz6g=="],
|
|
73
|
+
|
|
74
|
+
"@rollup/rollup-freebsd-arm64": ["@rollup/rollup-freebsd-arm64@4.68.9", "", { "os": "freebsd", "cpu": "arm64" }, "sha512-4YhNOyTvFKzrL0/abahYjSG1mIEFqFR+xtVom2T8prSk96z8aNgN3f8GUGCtkkC2eYbZvN9tUAGvgMgVq5FfXg=="],
|
|
75
|
+
|
|
76
|
+
"@rollup/rollup-freebsd-x64": ["@rollup/rollup-freebsd-x64@4.68.9", "", { "os": "freebsd", "cpu": "x64" }, "sha512-Ng7i+xFFd6I21dpTyA/1VKOuKVUCw5+s9kjeffTmg0OkP3Ldnf2F+XcmNfFAqIirK4Nadi505MVG6delN4XqMw=="],
|
|
77
|
+
|
|
78
|
+
"@rollup/rollup-linux-arm-gnueabihf": ["@rollup/rollup-linux-arm-gnueabihf@4.68.9", "", { "os": "linux", "cpu": "arm" }, "sha512-J9JGwMHb6B2Pi6ewp6kVMhzKHSblqC5QS5gV5u8NKw7semdTzETwwZeJLLUfV3YQqAAQxXNz5FGZDGukcwgO4A=="],
|
|
79
|
+
|
|
80
|
+
"@rollup/rollup-linux-arm-musleabihf": ["@rollup/rollup-linux-arm-musleabihf@4.68.9", "", { "os": "linux", "cpu": "arm" }, "sha512-cD3CbynGfXBU0BKX6AJ2TCqyd14ChhDQsH2P6BMAKSQaDXGzY1DUPZoQWcNXeJnsTqmoEWo59VlKgnZ9iAAd1w=="],
|
|
81
|
+
|
|
82
|
+
"@rollup/rollup-linux-arm64-gnu": ["@rollup/rollup-linux-arm64-gnu@4.68.9", "", { "os": "linux", "cpu": "arm64" }, "sha512-pEMURtf2ARso1VzpDp66G7FGdvpHcOKAT1+9TEqbbkWZ2ek91/KUGSP7RUSH1io8JpZiBkvoNhwELdgHH9b38g=="],
|
|
83
|
+
|
|
84
|
+
"@rollup/rollup-linux-arm64-musl": ["@rollup/rollup-linux-arm64-musl@4.68.9", "", { "os": "linux", "cpu": "arm64" }, "sha512-x3Ei7a0FYjMe2FMonmgjtRqVlCmrek2NgWC57b4mUbpwtHI9mZV58F0aEdTeA90U0liRks/NRXGQSVETsGP1kg=="],
|
|
85
|
+
|
|
86
|
+
"@rollup/rollup-linux-loong64-gnu": ["@rollup/rollup-linux-loong64-gnu@4.68.9", "", { "os": "linux", "cpu": "none" }, "sha512-teiOZq8Eka0Yb3IJypBc4dq2U3u5l6P1vZ4sVjOPWJhOFBeOc3bjUnxv2RHn88jsL2qwX4tXuPc0MoqTO+8gww=="],
|
|
87
|
+
|
|
88
|
+
"@rollup/rollup-linux-loong64-musl": ["@rollup/rollup-linux-loong64-musl@4.68.9", "", { "os": "linux", "cpu": "none" }, "sha512-51rITRfuF6LN+kZgAdYwk7qkQFlO87Tm1L/nO34kWEIuu8tJmMn1EBdBNdCOM68f93dILWY64QZECKcW2j2i7Q=="],
|
|
89
|
+
|
|
90
|
+
"@rollup/rollup-linux-ppc64-gnu": ["@rollup/rollup-linux-ppc64-gnu@4.68.9", "", { "os": "linux", "cpu": "ppc64" }, "sha512-nA1dtgROg2B4FPJbp3cpldu1dfbAs/uGFGsy+ZgZyIojvrGldgdeasnsKHNRuDI6gF47mb63rge6GKZHCiItuA=="],
|
|
91
|
+
|
|
92
|
+
"@rollup/rollup-linux-ppc64-musl": ["@rollup/rollup-linux-ppc64-musl@4.68.9", "", { "os": "linux", "cpu": "ppc64" }, "sha512-BG9NS84ehLVomSi35jSFDeMCRL+Mkz0PsBrjuAkgGHT/k+ZZIQ6rlQBmrAa11q/voQsiH8UeaUzi4FZFQn3syw=="],
|
|
93
|
+
|
|
94
|
+
"@rollup/rollup-linux-riscv64-gnu": ["@rollup/rollup-linux-riscv64-gnu@4.68.9", "", { "os": "linux", "cpu": "none" }, "sha512-771hNPYszO5g7FeqxR4LO8Qmi2xpjRcXjXfMYsgXLFz+5bNkCR4OPllgyz65v9wlTX4ZoVmbh8pCZhpm2LsykA=="],
|
|
95
|
+
|
|
96
|
+
"@rollup/rollup-linux-riscv64-musl": ["@rollup/rollup-linux-riscv64-musl@4.68.9", "", { "os": "linux", "cpu": "none" }, "sha512-zLCA6Rw0J04hsqogzzsUxEUr5jaInUgqkKnw3WsSHuCSQPbXWexrgphDDRJZGMeSCn2GQP7gJtzq/I5NwzVc3w=="],
|
|
97
|
+
|
|
98
|
+
"@rollup/rollup-linux-s390x-gnu": ["@rollup/rollup-linux-s390x-gnu@4.68.9", "", { "os": "linux", "cpu": "s390x" }, "sha512-TDl99JOOD8/uz6I3ECtboFOTZzodZ4VzJqfVjHqCo12fF+F/3bcf4dC5UC3lsGXQCGBMCxGZqrjj3h7fQijf1Q=="],
|
|
99
|
+
|
|
100
|
+
"@rollup/rollup-linux-x64-gnu": ["@rollup/rollup-linux-x64-gnu@4.68.9", "", { "os": "linux", "cpu": "x64" }, "sha512-oagkVYyesngXT4SmFKcGigT1rOZm/uYYowzg7JPP2k9wngF8cw8Kaunzn+HjejJl+Ec2ZD1F68hiXw2FB4cHYA=="],
|
|
101
|
+
|
|
102
|
+
"@rollup/rollup-linux-x64-musl": ["@rollup/rollup-linux-x64-musl@4.68.9", "", { "os": "linux", "cpu": "x64" }, "sha512-uDyXfmD1FCL+6WtyjhHDjqBKl4j0Kej11iQybR6+h72o5fFL6xyEmWsQWoMngJph9tOeiCeD45f+X0OccYyRlQ=="],
|
|
103
|
+
|
|
104
|
+
"@rollup/rollup-openbsd-x64": ["@rollup/rollup-openbsd-x64@4.68.9", "", { "os": "openbsd", "cpu": "x64" }, "sha512-sHr4zSqntivPmVau57RrRBMEoTqW8V/iLLfWghbvWcLMOR9PuswVASI4cGA4rJ3PLt8rynrNGK5tVftrH2g+dw=="],
|
|
105
|
+
|
|
106
|
+
"@rollup/rollup-openharmony-arm64": ["@rollup/rollup-openharmony-arm64@4.68.9", "", { "os": "none", "cpu": "arm64" }, "sha512-WCZET31LREmsAQCWictbgAdkJLejg7Gzm7hYL51wEROMZ7gziQK38WEfLKRp1Rdm2jnwnLxoJu7ttpjHQWr9CQ=="],
|
|
107
|
+
|
|
108
|
+
"@rollup/rollup-win32-arm64-msvc": ["@rollup/rollup-win32-arm64-msvc@4.68.9", "", { "os": "win32", "cpu": "arm64" }, "sha512-UwlCeuUlZqWrLpw4LuMgfpp+2e0HOe7cnbkUPoICxCtAFVv3IaB1qKfGaC/iRG3T29hGuzX1Dr20/rqtuVN4bw=="],
|
|
109
|
+
|
|
110
|
+
"@rollup/rollup-win32-ia32-msvc": ["@rollup/rollup-win32-ia32-msvc@4.68.9", "", { "os": "win32", "cpu": "ia32" }, "sha512-NgU7PKTSftWBK2wecMH/McGvM3a4nSa/I8zoS8o22sjPSScuGGyAfr1FoDQWEs+iuvFEQ/PKuRcZ3vO5u0Xqjw=="],
|
|
111
|
+
|
|
112
|
+
"@rollup/rollup-win32-x64-gnu": ["@rollup/rollup-win32-x64-gnu@4.68.9", "", { "os": "win32", "cpu": "x64" }, "sha512-xbFrHua9IPguaCF7I2bRiebq/OGdIJbHbTUruHMrVD91CcIxhNRpkl2JAiGEPpPaqW7hJLUbroXQ07Kde/ziGg=="],
|
|
113
|
+
|
|
114
|
+
"@rollup/rollup-win32-x64-msvc": ["@rollup/rollup-win32-x64-msvc@4.68.9", "", { "os": "win32", "cpu": "x64" }, "sha512-7xXs09Zvhwb0aaVJQ+t+NZYp/G7SMKxt+0BVsoNVP1ckLsTxazNBeqL8b91STBOOPj0o/6NEGLXnFaICm9Yi5Q=="],
|
|
115
|
+
|
|
116
|
+
"@types/bun": ["@types/bun@1.4.5", "", { "dependencies": { "bun-types": "1.4.5" } }, "sha512-DpgwNI9z0L1S0gtb45QLCWgwCUcMLnsHYMJHQvpNj7erGiCGBvpggltAIeARrtobNMKMuy0UP7i56tKKgwFs/Q=="],
|
|
117
|
+
|
|
118
|
+
"@types/estree": ["@types/estree@1.0.11", "", {}, "sha512-YBdNe5JcjYR0sPhJW1QIeRCmI11YhYvaRuGCs9+WCeTTb+Yhb2BE2XMe5/wAqF10FK5g3+q1PDhQABfT7aX0gg=="],
|
|
119
|
+
|
|
120
|
+
"@types/highlight.js": ["@types/highlight.js@10.1.0", "", { "dependencies": { "highlight.js": "*" } }, "sha512-77hF2dGBsOgnvZll1vymYiNUtqJ8cJfXPD6GG/2M0aLRc29PkvB7Au6sIDjIEFcSICBhCh2+Pyq6WSRS7LUm6A=="],
|
|
121
|
+
|
|
122
|
+
"@types/node": ["@types/node@26.6.11", "", { "dependencies": { "undici-types": "~8.9.0" } }, "sha512-uUyQ2XLEz+EXh34lmS3GhKrkqn/8FU7KUiKRpk347At2bmnMVWss45yz8b4FG/tUtmV1tV/+TVkITItPROyeeQ=="],
|
|
123
|
+
|
|
124
|
+
"bun-types": ["bun-types@1.4.5", "", { "dependencies": { "@types/node": "*", "undici-types": "*" } }, "sha512-ECHn+9dhL3wv0G6u0+7dQvrnaimXiRDxxerYBmhTaLyJEEuvTPWk2Fye3XIf5Y++JIIiHKfQw4Z7V5D8KuiXbg=="],
|
|
125
|
+
|
|
126
|
+
"esbuild": ["esbuild@0.21.5", "", { "optionalDependencies": { "@esbuild/aix-ppc64": "0.21.5", "@esbuild/android-arm": "0.21.5", "@esbuild/android-arm64": "0.21.5", "@esbuild/android-x64": "0.21.5", "@esbuild/darwin-arm64": "0.21.5", "@esbuild/darwin-x64": "0.21.5", "@esbuild/freebsd-arm64": "0.21.5", "@esbuild/freebsd-x64": "0.21.5", "@esbuild/linux-arm": "0.21.5", "@esbuild/linux-arm64": "0.21.5", "@esbuild/linux-ia32": "0.21.5", "@esbuild/linux-loong64": "0.21.5", "@esbuild/linux-mips64el": "0.21.5", "@esbuild/linux-ppc64": "0.21.5", "@esbuild/linux-riscv64": "0.21.5", "@esbuild/linux-s390x": "0.21.5", "@esbuild/linux-x64": "0.21.5", "@esbuild/netbsd-x64": "0.21.5", "@esbuild/openbsd-x64": "0.21.5", "@esbuild/sunos-x64": "0.21.5", "@esbuild/win32-arm64": "0.21.5", "@esbuild/win32-ia32": "0.21.5", "@esbuild/win32-x64": "0.21.5" }, "bin": { "esbuild": "bin/esbuild" } }, "sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw=="],
|
|
127
|
+
|
|
128
|
+
"fsevents": ["fsevents@2.3.3", "", { "os": "darwin" }, "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw=="],
|
|
129
|
+
|
|
130
|
+
"highlight.js": ["highlight.js@11.12.0", "", {}, "sha512-nbfWpyRMcMrPMmDwJB+dhX/eiaPKtc2RB+0QZskqJ3WjRA/FDS0e9hZrx8EC/lbEv8gXy98FcDbNa/dspAaJMg=="],
|
|
131
|
+
|
|
132
|
+
"nanoid": ["nanoid@3.3.20", "", { "bin": { "nanoid": "bin/nanoid.cjs" } }, "sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ=="],
|
|
133
|
+
|
|
134
|
+
"picocolors": ["picocolors@1.1.1", "", {}, "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA=="],
|
|
135
|
+
|
|
136
|
+
"postcss": ["postcss@8.5.34", "", { "dependencies": { "nanoid": "^3.3.20", "picocolors": "^1.1.1", "source-map-js": "^1.2.4" } }, "sha512-P1Qzj0XXZjMda74C7qiVnBG90UKNbyNUAOeQRBW8X63RsIMV57gevRqjnkELdwtZ/S2/uQFksJhmwuN8xShLPw=="],
|
|
137
|
+
|
|
138
|
+
"rollup": ["rollup@4.68.9", "", { "dependencies": { "@types/estree": "^1.0.10" }, "optionalDependencies": { "@rollup/rollup-android-arm-eabi": "4.68.9", "@rollup/rollup-android-arm64": "4.68.9", "@rollup/rollup-android-x64": "4.68.9", "@rollup/rollup-darwin-arm64": "4.68.9", "@rollup/rollup-darwin-x64": "4.68.9", "@rollup/rollup-freebsd-arm64": "4.68.9", "@rollup/rollup-freebsd-x64": "4.68.9", "@rollup/rollup-linux-arm-gnueabihf": "4.68.9", "@rollup/rollup-linux-arm-musleabihf": "4.68.9", "@rollup/rollup-linux-arm64-gnu": "4.68.9", "@rollup/rollup-linux-arm64-musl": "4.68.9", "@rollup/rollup-linux-loong64-gnu": "4.68.9", "@rollup/rollup-linux-loong64-musl": "4.68.9", "@rollup/rollup-linux-ppc64-gnu": "4.68.9", "@rollup/rollup-linux-ppc64-musl": "4.68.9", "@rollup/rollup-linux-riscv64-gnu": "4.68.9", "@rollup/rollup-linux-riscv64-musl": "4.68.9", "@rollup/rollup-linux-s390x-gnu": "4.68.9", "@rollup/rollup-linux-x64-gnu": "4.68.9", "@rollup/rollup-linux-x64-musl": "4.68.9", "@rollup/rollup-openbsd-x64": "4.68.9", "@rollup/rollup-openharmony-arm64": "4.68.9", "@rollup/rollup-win32-arm64-msvc": "4.68.9", "@rollup/rollup-win32-ia32-msvc": "4.68.9", "@rollup/rollup-win32-x64-gnu": "4.68.9", "@rollup/rollup-win32-x64-msvc": "4.68.9", "fsevents": "~2.3.2" }, "bin": { "rollup": "dist/bin/rollup" } }, "sha512-cv6sHP984hH1Wo4m1yBwyYOTtOVczamnB4KapDqQHCJZLVsMNDsEEP3/+6mHkt7NIAeVGPoE+fFKXRBL5dIjHg=="],
|
|
139
|
+
|
|
140
|
+
"source-map-js": ["source-map-js@1.2.4", "", {}, "sha512-J7ZjMvHd9O1fcT/5V09QWaaSl2BbWx3F6O08spde82Namf9UB0GxRVIPiNbVsdKkoizHiSpTodo3vp2bAy91MA=="],
|
|
141
|
+
|
|
142
|
+
"typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="],
|
|
143
|
+
|
|
144
|
+
"undici-types": ["undici-types@8.14.0", "", {}, "sha512-adaTpowOLjSeKhwA1+gEN/F8Bw/wmKH7Csw+01zmDB1TAYJ+COEn/Cfb9RXSUdssbZOdPBRvI6wOubXyzbiotQ=="],
|
|
145
|
+
|
|
146
|
+
"vite": ["vite@5.4.21", "", { "dependencies": { "esbuild": "^0.21.3", "postcss": "^8.4.43", "rollup": "^4.20.0" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "peerDependencies": { "@types/node": "^18.0.0 || >=20.0.0", "less": "*", "lightningcss": "^1.21.0", "sass": "*", "sass-embedded": "*", "stylus": "*", "sugarss": "*", "terser": "^5.4.0" }, "optionalPeers": ["@types/node", "less", "lightningcss", "sass", "sass-embedded", "stylus", "sugarss", "terser"], "bin": { "vite": "bin/vite.js" } }, "sha512-o5a9xKjbtuhY6Bi5S3+HvbRERmouabWbyUcpXXUA1u+GNUKoROi9byOJ8M0nHbHYHkYICiMlqxkg1KkYmm25Sw=="],
|
|
147
|
+
|
|
148
|
+
"@types/node/undici-types": ["undici-types@8.9.0", "", {}, "sha512-KTDyRTYX8sWmKXAikPHHSyc63CRPETMctyjKFupcC6OBLXT3xsN0e9aF7m+mIXutFWpUXuedtowG7iLOzp0kQg=="],
|
|
149
|
+
}
|
|
150
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exercism/highlightjs-racket",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Racket language support for Highlight.js",
|
|
5
|
+
"author": "Exercism",
|
|
6
|
+
"license": "MIT AND BSD-3-Clause",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/exercism/highlightjs-racket.git"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"racket",
|
|
13
|
+
"highlight.js",
|
|
14
|
+
"highlightjs",
|
|
15
|
+
"syntax"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"prepare": "bun build --minify src/racket.ts --outdir src",
|
|
19
|
+
"test": "bun test",
|
|
20
|
+
"render": "bun bin/render-solutions",
|
|
21
|
+
"dev": "vite"
|
|
22
|
+
},
|
|
23
|
+
"type": "module",
|
|
24
|
+
"module": "src/racket.ts",
|
|
25
|
+
"main": "src/racket.js",
|
|
26
|
+
"types": "src/racket.d.ts",
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/bun": "latest",
|
|
32
|
+
"@types/highlight.js": "^10.1.0",
|
|
33
|
+
"highlight.js": "^11.10.0",
|
|
34
|
+
"vite": "^5.4.11"
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"typescript": "^5.4.5"
|
|
38
|
+
}
|
|
39
|
+
}
|
package/src/racket.d.ts
ADDED
package/src/racket.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var g=["","/list","/vector","/hash","/hasheq","/hasheqv","/hashalw","/and","/or","/sum","/product","/lists","/first","/last","/fold","/foldr","/set","/seteq","/seteqv","/setalw","/mutable-set","/stream","/string"],r=[...g.flatMap((m)=>[`for${m}`,`for*${m}`]),"define","define-values","define-syntax","define-syntaxes","define-syntax-rule","define-for-syntax","define-struct","define/contract","define/match","define/public","define/private","define/override","define/augment","define/pubment","define/public-final","define/override-final","define/augment-final","define-match-expander","define-logger","define-namespace-anchor","struct","struct-copy","struct/contract","lambda","λ","case-lambda","let","let*","letrec","let-values","let*-values","letrec-values","let-syntax","letrec-syntax","let-syntaxes","letrec-syntaxes","let/ec","let/cc","local","shared","if","cond","case","when","unless","else","=>","and","or","begin","begin0","do","set!","set!-values","quote","quasiquote","unquote","unquote-splicing","syntax","quasisyntax","unsyntax","unsyntax-splicing","syntax-rules","syntax-case","syntax-case*","syntax-parse","with-syntax","syntax-id-rules","begin-for-syntax","module","module*","module+","require","provide","only-in","except-in","prefix-in","rename-in","combine-in","for-syntax","for-template","for-label","all-defined-out","all-from-out","rename-out","except-out","prefix-out","struct-out","contract-out","combine-out","protect-out","match","match*","match-define","match-let","match-let*","match-letrec","match-lambda","match-lambda*","match-lambda**","parameterize","parameterize*","with-handlers","with-handlers*","delay","lazy","delay/name","thunk","thunk*","class","class*","mixin","interface","interface*","new","send","send*","send/apply","get-field","set-field!","field","init","init-field","inherit","inherit-field","super","super-new","this","public","private","override","augment","assert","time","case-λ","for/async"],U=["cons","car","cdr","caar","cadr","cdar","cddr","caddr","cdddr","cadddr","list","list*","build-list","length","list-ref","list-tail","append","reverse","map","andmap","ormap","for-each","foldl","foldr","filter","remove","remq","remv","remove*","sort","member","memq","memv","memf","assoc","assq","assv","assf","findf","first","second","third","fourth","fifth","last","rest","last-pair","empty?","cons?","make-list","list-set","list-update","index-of","indexes-of","take","drop","take-right","drop-right","split-at","takef","dropf","splitf-at","add-between","append*","flatten","check-duplicates","remove-duplicates","filter-map","count","partition","range","inclusive-range","append-map","filter-not","shuffle","combinations","permutations","in-combinations","in-permutations","argmin","argmax","group-by","cartesian-product","list-prefix?","make-string","apply","+","-","*","/","=","<",">","<=",">=","abs","max","min","add1","sub1","quotient","remainder","modulo","quotient/remainder","gcd","lcm","expt","exp","log","sqrt","integer-sqrt","sqr","floor","ceiling","round","truncate","exact-round","exact-floor","exact-ceiling","exact-truncate","exact->inexact","inexact->exact","exact","inexact","numerator","denominator","number->string","string->number","zero?","positive?","negative?","even?","odd?","number?","integer?","exact-integer?","exact-nonnegative-integer?","exact-positive-integer?","natural?","rational?","real?","complex?","exact?","inexact?","nan?","infinite?","sin","cos","tan","asin","acos","atan","pi","random","bitwise-and","bitwise-ior","bitwise-xor","bitwise-not","bitwise-bit-set?","arithmetic-shift","integer-length","order-of-magnitude","not","equal?","eqv?","eq?","boolean?","null?","pair?","list?","procedure?","symbol?","string?","char?","vector?","hash?","void?","void","identity","const","curry","curryr","compose","compose1","negate","conjoin","disjoin","values","call-with-values","call/cc","call-with-current-continuation","call/ec","dynamic-wind","implies","xor","nand","nor","string","string-length","string-ref","substring","string-append","string-append*","string-join","string-split","string-trim","string-upcase","string-downcase","string-titlecase","string-foldcase","string-replace","string-prefix?","string-suffix?","string-contains?","string->list","list->string","string->symbol","symbol->string","string->keyword","keyword->string","string-copy","string-set!","string-fill!","build-string","string=?","string<?","string>?","string<=?","string>=?","string-ci=?","string-ci<?","non-empty-string?","string-normalize-spaces","string->bytes/utf-8","bytes->string/utf-8","char->integer","integer->char","char-upcase","char-downcase","char-alphabetic?","char-numeric?","char-whitespace?","char-upper-case?","char-lower-case?","char-punctuation?","char=?","char<?","char>?","char<=?","char>=?","char-ci=?","symbol<?","gensym","format","printf","fprintf","eprintf","display","displayln","write","writeln","print","println","newline","~a","~s","~v","~r","~e","read-line","read","read-char","with-output-to-string","with-input-from-string","open-input-string","open-output-string","get-output-string","current-output-port","current-input-port","current-error-port","regexp","pregexp","regexp-match","regexp-match*","regexp-match?","regexp-match-exact?","regexp-match-positions","regexp-replace","regexp-replace*","regexp-split","regexp-quote","vector","make-vector","build-vector","vector-ref","vector-set!","vector-length","vector->list","list->vector","vector-map","vector-map!","vector-fill!","vector-copy","vector-append","vector-member","vector-memq","vector-count","vector-filter","vector-argmin","vector-argmax","vector-sort","vector-sort!","vector->immutable-vector","vector-take","vector-drop","hash","hasheq","hasheqv","make-hash","make-hasheq","make-hasheqv","make-immutable-hash","hash-ref","hash-ref!","hash-set","hash-set!","hash-set*","hash-update","hash-update!","hash-remove","hash-remove!","hash-has-key?","hash-keys","hash-values","hash->list","hash-count","hash-map","hash-for-each","hash-empty?","hash-union","hash-union!","hash-copy","hash-clear!","set","seteq","list->set","set->list","set-member?","set-add","set-remove","set-union","set-intersect","set-subtract","set-count","subset?","set-empty?","mutable-set","set-add!","in-range","in-inclusive-range","in-naturals","in-list","in-vector","in-string","in-hash","in-hash-keys","in-hash-values","in-hash-pairs","in-set","in-value","in-indexed","in-cycle","in-parallel","in-sequences","in-producer","in-port","in-lines","in-bytes","in-stream","in-slice","sequence->list","sequence->stream","stream","stream-cons","stream-first","stream-rest","stream-empty?","stream->list","box","unbox","set-box!","file->string","file->lines","file->list","display-to-file","write-to-file","display-lines-to-file","file-exists?","with-input-from-file","with-output-to-file","open-input-file","open-output-file","close-input-port","close-output-port","thread","thread-wait","sleep","make-semaphore","semaphore-post","semaphore-wait","channel-get","channel-put","make-channel","current-seconds","current-milliseconds","current-inexact-milliseconds","seconds->date","find-seconds","date->seconds","error","raise","raise-argument-error","raise-user-error","raise-arguments-error","exn:fail?","exn:fail:contract?","exn-message","exn?","make-parameter","->","->*","->i","any/c","none/c","or/c","and/c","not/c","listof","non-empty-listof","vectorof","hash/c","cons/c","list/c","one-of/c","between/c","natural-number/c","integer-in","real-in","string-len/c","parameter/c","procedure-arity-includes/c","any","struct/c"],t=["true","false","null","empty","eof","+inf.0","-inf.0","+nan.0","-nan.0"],k=/[^\s()[\]{}",'`;#|\\][^\s()[\]{}",'`;|\\]*/,w=/(?=[\s()[\]{}",'`;]|$)/.source;function M(m){let b=m.regex,$={$pattern:k,keyword:r,built_in:U,literal:t},u={scope:"meta",begin:/#(?:lang|reader)\b/,end:/$/},H={scope:"literal",begin:b.concat(/#(?:true|false|t|f|T|F)/,w)},P={scope:"string",begin:b.concat(/#\\/,b.either(b.concat(/(?:null|nul|backspace|tab|newline|linefeed|vtab|page|return|space|rubout|delete)/,w),/u[0-9a-fA-F]{1,4}/,/U[0-9a-fA-F]{1,8}/,/[0-7]{3}/,/[\s\S]/))},q={scope:"number",relevance:0,variants:[{begin:b.concat(/(?:#[eEiI])?(?:#[dD])?/,/[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?(?:\/\d+)?/,/(?:[+-](?:\d+(?:\.\d*)?|\.\d+)?(?:\/\d+)?i)?/,w)},{begin:b.concat(/[+-](?:inf|nan)\.[0ft]/,w)},{begin:b.concat(/(?:#[eEiI])?#[xX][+-]?[0-9a-fA-F]+(?:\/[0-9a-fA-F]+)?/,w)},{begin:b.concat(/(?:#[eEiI])?#[oO][+-]?[0-7]+(?:\/[0-7]+)?/,w)},{begin:b.concat(/(?:#[eEiI])?#[bB][+-]?[01]+(?:\/[01]+)?/,w)}]},y={scope:"string",variants:[{begin:/#?"/,end:/"/}],contains:[m.BACKSLASH_ESCAPE]},G={scope:"regexp",begin:/#[rp]x#?"/,end:/"/,contains:[m.BACKSLASH_ESCAPE]},c={scope:"attr",begin:b.concat(/#:/,k),relevance:10},Q=m.COMMENT(/#\|/,/\|#/,{contains:["self"]}),X={variants:[{begin:/\(/,end:/\)/},{begin:/\[/,end:/\]/},{begin:/\{/,end:/\}/}],contains:["self",y]},a={scope:"comment",variants:[{begin:/#;\s*\(/,end:/\)/},{begin:/#;\s*\[/,end:/\]/},{begin:/#;\s*\{/,end:/\}/},{begin:b.concat(/#;\s*/,k)}],contains:[X,y]},F=[m.COMMENT(/;/,/$/,{relevance:0}),Q,a],z={begin:k,keywords:{$pattern:k,literal:t},relevance:0},V={scope:"symbol",begin:b.concat(/(?:'|#')/,k)},J=[],n=(i)=>[[/\(/,/\)/],[/\[/,/\]/],[/\{/,/\}/]].map(([l,C])=>({begin:b.concat(i,l),end:C,contains:J})),d={begin:[/'?/,/#hash(?:eqv|eq|alw)?/,/\(/],beginScope:{2:"literal"},end:/\)/,contains:J},p=/(?:'|`|#'|#`)/,Z=/#(?:s|&)?/,v={endsWithParent:!0,relevance:0},f={scope:"name",relevance:0,begin:k,keywords:$},B={relevance:0,begin:k,keywords:$},K={variants:[{begin:/\(/,end:/\)/},{begin:/\{/,end:/\}/}],contains:[{begin:[/define(?:\/[a-z-]+|-syntax-rule)?/,/\s+/,/\(/,/\s*/,k],beginScope:{1:"keyword",5:"title.function"},end:/\)/,contains:[v]},{begin:[/struct|define-struct/,/\s+/,k],beginScope:{1:"keyword",3:"title.class"},endsWithParent:!0,contains:[{begin:/\(/,end:/\)/,endsParent:!0,contains:[v]},z]},{begin:/(?:lambda|λ)(?=\s*[([])/,beginScope:"keyword",endsWithParent:!0,contains:[{endsParent:!0,variants:[{begin:/\(/,end:/\)/},{begin:/\[/,end:/\]/}],contains:[c,v]}]},q,f,v]},W={begin:/\[/,end:/\]/,contains:[B,v]},h={variants:[{begin:/#?,@?\(/,end:/\)/},{begin:/#?,@?\{/,end:/\}/}],contains:K.contains},j={begin:/#?,@?\[/,end:/\]/,contains:W.contains},Y={begin:b.concat(/#?,@?/,k),relevance:0},o=[u,H,P,G,y,c,q,...F];return J.push(...o,h,j,Y,d,...n(b.concat(b.optional(p),b.optional(Z))),V,z),v.contains=[...o,d,...n(b.either(b.concat(p,b.optional(Z)),Z)),V,z,K,W],{name:"Racket",aliases:["rkt"],contains:[m.SHEBANG(),...v.contains]}}export{M as default};
|
package/src/racket.ts
ADDED
|
@@ -0,0 +1,490 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Language: Racket
|
|
3
|
+
Description: Racket is a general-purpose programming language in the Lisp and Scheme family.
|
|
4
|
+
Category: lisp
|
|
5
|
+
Author: Exercism
|
|
6
|
+
Website: https://racket-lang.org/
|
|
7
|
+
|
|
8
|
+
This grammar started as a hard fork of the Scheme grammar in highlight.js
|
|
9
|
+
(src/languages/scheme.js, by JP Verkamp and Ivan Sagalaev), which is under
|
|
10
|
+
the following licence:
|
|
11
|
+
|
|
12
|
+
BSD 3-Clause License
|
|
13
|
+
|
|
14
|
+
Copyright (c) 2006, Ivan Sagalaev.
|
|
15
|
+
All rights reserved.
|
|
16
|
+
|
|
17
|
+
Redistribution and use in source and binary forms, with or without
|
|
18
|
+
modification, are permitted provided that the following conditions are met:
|
|
19
|
+
|
|
20
|
+
* Redistributions of source code must retain the above copyright notice, this
|
|
21
|
+
list of conditions and the following disclaimer.
|
|
22
|
+
|
|
23
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
|
24
|
+
this list of conditions and the following disclaimer in the documentation
|
|
25
|
+
and/or other materials provided with the distribution.
|
|
26
|
+
|
|
27
|
+
* Neither the name of the copyright holder nor the names of its
|
|
28
|
+
contributors may be used to endorse or promote products derived from
|
|
29
|
+
this software without specific prior written permission.
|
|
30
|
+
|
|
31
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
32
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
33
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
34
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
35
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
36
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
37
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
38
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
39
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
40
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
import { type HLJSApi, type Language, type Mode } from "highlight.js";
|
|
44
|
+
|
|
45
|
+
// Syntactic forms from racket/base, racket/match, racket/contract and
|
|
46
|
+
// racket/class. The `for` loops come in many flavours, so they are built
|
|
47
|
+
// from their suffixes: `for/list`, `for*/fold` and so on.
|
|
48
|
+
const FOR_SUFFIXES = [
|
|
49
|
+
"", "/list", "/vector", "/hash", "/hasheq", "/hasheqv", "/hashalw",
|
|
50
|
+
"/and", "/or", "/sum", "/product", "/lists", "/first", "/last",
|
|
51
|
+
"/fold", "/foldr", "/set", "/seteq", "/seteqv", "/setalw",
|
|
52
|
+
"/mutable-set", "/stream", "/string",
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
const KEYWORDS = [
|
|
56
|
+
...FOR_SUFFIXES.flatMap((suffix) => [`for${suffix}`, `for*${suffix}`]),
|
|
57
|
+
"define", "define-values", "define-syntax", "define-syntaxes",
|
|
58
|
+
"define-syntax-rule", "define-for-syntax", "define-struct",
|
|
59
|
+
"define/contract", "define/match", "define/public", "define/private",
|
|
60
|
+
"define/override", "define/augment", "define/pubment",
|
|
61
|
+
"define/public-final", "define/override-final", "define/augment-final",
|
|
62
|
+
"define-match-expander", "define-logger", "define-namespace-anchor",
|
|
63
|
+
"struct", "struct-copy", "struct/contract",
|
|
64
|
+
"lambda", "λ", "case-lambda",
|
|
65
|
+
"let", "let*", "letrec", "let-values", "let*-values", "letrec-values",
|
|
66
|
+
"let-syntax", "letrec-syntax", "let-syntaxes", "letrec-syntaxes",
|
|
67
|
+
"let/ec", "let/cc", "local", "shared",
|
|
68
|
+
"if", "cond", "case", "when", "unless", "else", "=>", "and", "or",
|
|
69
|
+
"begin", "begin0", "do", "set!", "set!-values",
|
|
70
|
+
"quote", "quasiquote", "unquote", "unquote-splicing",
|
|
71
|
+
"syntax", "quasisyntax", "unsyntax", "unsyntax-splicing",
|
|
72
|
+
"syntax-rules", "syntax-case", "syntax-case*", "syntax-parse",
|
|
73
|
+
"with-syntax", "syntax-id-rules", "begin-for-syntax",
|
|
74
|
+
"module", "module*", "module+", "require", "provide",
|
|
75
|
+
"only-in", "except-in", "prefix-in", "rename-in", "combine-in",
|
|
76
|
+
"for-syntax", "for-template", "for-label",
|
|
77
|
+
"all-defined-out", "all-from-out", "rename-out", "except-out",
|
|
78
|
+
"prefix-out", "struct-out", "contract-out", "combine-out", "protect-out",
|
|
79
|
+
"match", "match*", "match-define", "match-let", "match-let*",
|
|
80
|
+
"match-letrec", "match-lambda", "match-lambda*", "match-lambda**",
|
|
81
|
+
"parameterize", "parameterize*", "with-handlers", "with-handlers*",
|
|
82
|
+
"delay", "lazy", "delay/name", "thunk", "thunk*",
|
|
83
|
+
"class", "class*", "mixin", "interface", "interface*", "new", "send",
|
|
84
|
+
"send*", "send/apply", "get-field", "set-field!", "field", "init",
|
|
85
|
+
"init-field", "inherit", "inherit-field", "super", "super-new", "this",
|
|
86
|
+
"public", "private", "override", "augment",
|
|
87
|
+
"assert", "time", "case-λ", "for/async",
|
|
88
|
+
];
|
|
89
|
+
|
|
90
|
+
// Common procedures from racket/base, racket/list, racket/string,
|
|
91
|
+
// racket/math, racket/function and racket/contract.
|
|
92
|
+
const BUILT_INS = [
|
|
93
|
+
// Pairs and lists
|
|
94
|
+
"cons", "car", "cdr", "caar", "cadr", "cdar", "cddr", "caddr", "cdddr",
|
|
95
|
+
"cadddr", "list", "list*", "build-list", "length", "list-ref",
|
|
96
|
+
"list-tail", "append", "reverse", "map", "andmap", "ormap", "for-each",
|
|
97
|
+
"foldl", "foldr", "filter", "remove", "remq", "remv", "remove*",
|
|
98
|
+
"sort", "member", "memq", "memv", "memf", "assoc", "assq", "assv",
|
|
99
|
+
"assf", "findf", "first", "second", "third", "fourth", "fifth", "last",
|
|
100
|
+
"rest", "last-pair", "empty?", "cons?", "make-list", "list-set",
|
|
101
|
+
"list-update", "index-of", "indexes-of", "take", "drop", "take-right",
|
|
102
|
+
"drop-right", "split-at", "takef", "dropf", "splitf-at", "add-between",
|
|
103
|
+
"append*", "flatten", "check-duplicates", "remove-duplicates",
|
|
104
|
+
"filter-map", "count", "partition", "range", "inclusive-range",
|
|
105
|
+
"append-map", "filter-not", "shuffle", "combinations", "permutations",
|
|
106
|
+
"in-combinations", "in-permutations", "argmin", "argmax", "group-by",
|
|
107
|
+
"cartesian-product", "list-prefix?", "make-string", "apply",
|
|
108
|
+
// Numbers
|
|
109
|
+
"+", "-", "*", "/", "=", "<", ">", "<=", ">=", "abs", "max", "min",
|
|
110
|
+
"add1", "sub1", "quotient", "remainder", "modulo", "quotient/remainder",
|
|
111
|
+
"gcd", "lcm", "expt", "exp", "log", "sqrt", "integer-sqrt", "sqr",
|
|
112
|
+
"floor", "ceiling", "round", "truncate", "exact-round", "exact-floor",
|
|
113
|
+
"exact-ceiling", "exact-truncate", "exact->inexact", "inexact->exact",
|
|
114
|
+
"exact", "inexact", "numerator", "denominator", "number->string",
|
|
115
|
+
"string->number", "zero?", "positive?", "negative?", "even?", "odd?",
|
|
116
|
+
"number?", "integer?", "exact-integer?", "exact-nonnegative-integer?",
|
|
117
|
+
"exact-positive-integer?", "natural?", "rational?", "real?", "complex?",
|
|
118
|
+
"exact?", "inexact?", "nan?", "infinite?", "sin", "cos", "tan", "asin",
|
|
119
|
+
"acos", "atan", "pi", "random", "bitwise-and", "bitwise-ior",
|
|
120
|
+
"bitwise-xor", "bitwise-not", "bitwise-bit-set?", "arithmetic-shift",
|
|
121
|
+
"integer-length", "order-of-magnitude",
|
|
122
|
+
// Booleans and equality
|
|
123
|
+
"not", "equal?", "eqv?", "eq?", "boolean?", "null?", "pair?", "list?",
|
|
124
|
+
"procedure?", "symbol?", "string?", "char?", "vector?", "hash?", "void?",
|
|
125
|
+
"void", "identity", "const", "curry", "curryr", "compose", "compose1",
|
|
126
|
+
"negate", "conjoin", "disjoin", "values", "call-with-values",
|
|
127
|
+
"call/cc", "call-with-current-continuation", "call/ec", "dynamic-wind",
|
|
128
|
+
"implies", "xor", "nand", "nor",
|
|
129
|
+
// Strings, characters and symbols
|
|
130
|
+
"string", "string-length", "string-ref", "substring", "string-append",
|
|
131
|
+
"string-append*", "string-join", "string-split", "string-trim",
|
|
132
|
+
"string-upcase", "string-downcase", "string-titlecase", "string-foldcase",
|
|
133
|
+
"string-replace", "string-prefix?", "string-suffix?", "string-contains?",
|
|
134
|
+
"string->list", "list->string", "string->symbol", "symbol->string",
|
|
135
|
+
"string->keyword", "keyword->string", "string-copy", "string-set!",
|
|
136
|
+
"string-fill!", "build-string", "string=?", "string<?", "string>?",
|
|
137
|
+
"string<=?", "string>=?", "string-ci=?", "string-ci<?", "non-empty-string?",
|
|
138
|
+
"string-normalize-spaces", "string->bytes/utf-8", "bytes->string/utf-8",
|
|
139
|
+
"char->integer", "integer->char", "char-upcase", "char-downcase",
|
|
140
|
+
"char-alphabetic?", "char-numeric?", "char-whitespace?",
|
|
141
|
+
"char-upper-case?", "char-lower-case?", "char-punctuation?", "char=?",
|
|
142
|
+
"char<?", "char>?", "char<=?", "char>=?", "char-ci=?",
|
|
143
|
+
"symbol<?", "gensym", "format", "printf", "fprintf", "eprintf",
|
|
144
|
+
"display", "displayln", "write", "writeln", "print", "println", "newline",
|
|
145
|
+
"~a", "~s", "~v", "~r", "~e", "read-line", "read", "read-char",
|
|
146
|
+
"with-output-to-string", "with-input-from-string", "open-input-string",
|
|
147
|
+
"open-output-string", "get-output-string", "current-output-port",
|
|
148
|
+
"current-input-port", "current-error-port",
|
|
149
|
+
"regexp", "pregexp", "regexp-match", "regexp-match*", "regexp-match?",
|
|
150
|
+
"regexp-match-exact?", "regexp-match-positions", "regexp-replace",
|
|
151
|
+
"regexp-replace*", "regexp-split", "regexp-quote",
|
|
152
|
+
// Vectors, hashes, sets and sequences
|
|
153
|
+
"vector", "make-vector", "build-vector", "vector-ref", "vector-set!",
|
|
154
|
+
"vector-length", "vector->list", "list->vector", "vector-map",
|
|
155
|
+
"vector-map!", "vector-fill!", "vector-copy", "vector-append",
|
|
156
|
+
"vector-member", "vector-memq", "vector-count", "vector-filter",
|
|
157
|
+
"vector-argmin", "vector-argmax", "vector-sort", "vector-sort!",
|
|
158
|
+
"vector->immutable-vector", "vector-take", "vector-drop",
|
|
159
|
+
"hash", "hasheq", "hasheqv", "make-hash", "make-hasheq", "make-hasheqv",
|
|
160
|
+
"make-immutable-hash", "hash-ref", "hash-ref!", "hash-set", "hash-set!",
|
|
161
|
+
"hash-set*", "hash-update", "hash-update!", "hash-remove",
|
|
162
|
+
"hash-remove!", "hash-has-key?", "hash-keys", "hash-values",
|
|
163
|
+
"hash->list", "hash-count", "hash-map", "hash-for-each", "hash-empty?",
|
|
164
|
+
"hash-union", "hash-union!", "hash-copy", "hash-clear!",
|
|
165
|
+
"set", "seteq", "list->set", "set->list", "set-member?", "set-add",
|
|
166
|
+
"set-remove", "set-union", "set-intersect", "set-subtract", "set-count",
|
|
167
|
+
"subset?", "set-empty?", "mutable-set", "set-add!",
|
|
168
|
+
"in-range", "in-inclusive-range", "in-naturals", "in-list", "in-vector",
|
|
169
|
+
"in-string", "in-hash", "in-hash-keys", "in-hash-values",
|
|
170
|
+
"in-hash-pairs", "in-set", "in-value", "in-indexed", "in-cycle",
|
|
171
|
+
"in-parallel", "in-sequences", "in-producer", "in-port", "in-lines",
|
|
172
|
+
"in-bytes", "in-stream", "in-slice", "sequence->list", "sequence->stream",
|
|
173
|
+
"stream", "stream-cons", "stream-first", "stream-rest", "stream-empty?",
|
|
174
|
+
"stream->list", "box", "unbox", "set-box!",
|
|
175
|
+
// Files, threads and dates
|
|
176
|
+
"file->string", "file->lines", "file->list", "display-to-file",
|
|
177
|
+
"write-to-file", "display-lines-to-file", "file-exists?",
|
|
178
|
+
"with-input-from-file", "with-output-to-file", "open-input-file",
|
|
179
|
+
"open-output-file", "close-input-port", "close-output-port",
|
|
180
|
+
"thread", "thread-wait", "sleep", "make-semaphore", "semaphore-post",
|
|
181
|
+
"semaphore-wait", "channel-get", "channel-put", "make-channel",
|
|
182
|
+
"current-seconds", "current-milliseconds", "current-inexact-milliseconds",
|
|
183
|
+
"seconds->date", "find-seconds", "date->seconds",
|
|
184
|
+
// Errors and contracts
|
|
185
|
+
"error", "raise", "raise-argument-error", "raise-user-error",
|
|
186
|
+
"raise-arguments-error", "exn:fail?", "exn:fail:contract?",
|
|
187
|
+
"exn-message", "exn?", "make-parameter", "->", "->*", "->i", "any/c",
|
|
188
|
+
"none/c", "or/c", "and/c", "not/c", "listof", "non-empty-listof",
|
|
189
|
+
"vectorof", "hash/c", "cons/c", "list/c", "one-of/c", "between/c",
|
|
190
|
+
"natural-number/c", "integer-in", "real-in", "string-len/c",
|
|
191
|
+
"parameter/c", "procedure-arity-includes/c", "any", "struct/c",
|
|
192
|
+
];
|
|
193
|
+
|
|
194
|
+
const LITERALS = ["true", "false", "null", "empty", "eof", "+inf.0", "-inf.0", "+nan.0", "-nan.0"];
|
|
195
|
+
|
|
196
|
+
// Any run of characters that is not whitespace, a bracket, a quote or one
|
|
197
|
+
// of Racket's other delimiters. `#` may appear inside a name, but not at its
|
|
198
|
+
// start, where it begins a special form such as `#t` or `#:key`.
|
|
199
|
+
const IDENT_RE = /[^\s()[\]{}",'`;#|\\][^\s()[\]{}",'`;|\\]*/;
|
|
200
|
+
|
|
201
|
+
// Numbers, booleans and characters must end at a delimiter, so that `#true`
|
|
202
|
+
// isn't read as `#t` followed by `rue`, and `1+` isn't read as a number.
|
|
203
|
+
const DELIMITER = /(?=[\s()[\]{}",'`;]|$)/.source;
|
|
204
|
+
|
|
205
|
+
export default function (hljs: HLJSApi): Language {
|
|
206
|
+
const regex = hljs.regex;
|
|
207
|
+
|
|
208
|
+
const KEYWORDS_DICT = {
|
|
209
|
+
$pattern: IDENT_RE,
|
|
210
|
+
keyword: KEYWORDS,
|
|
211
|
+
built_in: BUILT_INS,
|
|
212
|
+
literal: LITERALS,
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
const LANG_LINE: Mode = {
|
|
216
|
+
scope: "meta",
|
|
217
|
+
begin: /#(?:lang|reader)\b/,
|
|
218
|
+
end: /$/,
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
const BOOLEAN: Mode = {
|
|
222
|
+
scope: "literal",
|
|
223
|
+
begin: regex.concat(/#(?:true|false|t|f|T|F)/, DELIMITER),
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
const CHARACTER: Mode = {
|
|
227
|
+
scope: "string",
|
|
228
|
+
begin: regex.concat(
|
|
229
|
+
/#\\/,
|
|
230
|
+
regex.either(
|
|
231
|
+
regex.concat(
|
|
232
|
+
/(?:null|nul|backspace|tab|newline|linefeed|vtab|page|return|space|rubout|delete)/,
|
|
233
|
+
DELIMITER,
|
|
234
|
+
),
|
|
235
|
+
/u[0-9a-fA-F]{1,4}/,
|
|
236
|
+
/U[0-9a-fA-F]{1,8}/,
|
|
237
|
+
/[0-7]{3}/,
|
|
238
|
+
/[\s\S]/,
|
|
239
|
+
),
|
|
240
|
+
),
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
const NUMBER: Mode = {
|
|
244
|
+
scope: "number",
|
|
245
|
+
relevance: 0,
|
|
246
|
+
variants: [
|
|
247
|
+
// Decimals, exponents, fractions and complex numbers, with an
|
|
248
|
+
// optional exactness prefix such as `#e`.
|
|
249
|
+
{
|
|
250
|
+
begin: regex.concat(
|
|
251
|
+
/(?:#[eEiI])?(?:#[dD])?/,
|
|
252
|
+
/[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?(?:\/\d+)?/,
|
|
253
|
+
/(?:[+-](?:\d+(?:\.\d*)?|\.\d+)?(?:\/\d+)?i)?/,
|
|
254
|
+
DELIMITER,
|
|
255
|
+
),
|
|
256
|
+
},
|
|
257
|
+
{ begin: regex.concat(/[+-](?:inf|nan)\.[0ft]/, DELIMITER) },
|
|
258
|
+
{ begin: regex.concat(/(?:#[eEiI])?#[xX][+-]?[0-9a-fA-F]+(?:\/[0-9a-fA-F]+)?/, DELIMITER) },
|
|
259
|
+
{ begin: regex.concat(/(?:#[eEiI])?#[oO][+-]?[0-7]+(?:\/[0-7]+)?/, DELIMITER) },
|
|
260
|
+
{ begin: regex.concat(/(?:#[eEiI])?#[bB][+-]?[01]+(?:\/[01]+)?/, DELIMITER) },
|
|
261
|
+
],
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
const STRING: Mode = {
|
|
265
|
+
scope: "string",
|
|
266
|
+
variants: [
|
|
267
|
+
// Strings, and byte strings such as #"bytes"
|
|
268
|
+
{ begin: /#?"/, end: /"/ },
|
|
269
|
+
],
|
|
270
|
+
contains: [hljs.BACKSLASH_ESCAPE],
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
const REGULAR_EXPRESSION: Mode = {
|
|
274
|
+
scope: "regexp",
|
|
275
|
+
begin: /#[rp]x#?"/,
|
|
276
|
+
end: /"/,
|
|
277
|
+
contains: [hljs.BACKSLASH_ESCAPE],
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
// `#:key` names a keyword argument.
|
|
281
|
+
const KEYWORD_ARGUMENT: Mode = {
|
|
282
|
+
scope: "attr",
|
|
283
|
+
begin: regex.concat(/#:/, IDENT_RE),
|
|
284
|
+
relevance: 10,
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
const NESTED_COMMENT: Mode = hljs.COMMENT(/#\|/, /\|#/, { contains: ["self"] });
|
|
288
|
+
|
|
289
|
+
// `#;` comments out the next datum, which may be a whole list.
|
|
290
|
+
const DATUM_COMMENT_LIST: Mode = {
|
|
291
|
+
variants: [
|
|
292
|
+
{ begin: /\(/, end: /\)/ },
|
|
293
|
+
{ begin: /\[/, end: /\]/ },
|
|
294
|
+
{ begin: /\{/, end: /\}/ },
|
|
295
|
+
],
|
|
296
|
+
contains: ["self", STRING],
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
const DATUM_COMMENT: Mode = {
|
|
300
|
+
scope: "comment",
|
|
301
|
+
variants: [
|
|
302
|
+
{ begin: /#;\s*\(/, end: /\)/ },
|
|
303
|
+
{ begin: /#;\s*\[/, end: /\]/ },
|
|
304
|
+
{ begin: /#;\s*\{/, end: /\}/ },
|
|
305
|
+
{ begin: regex.concat(/#;\s*/, IDENT_RE) },
|
|
306
|
+
],
|
|
307
|
+
contains: [DATUM_COMMENT_LIST, STRING],
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
const COMMENTS: Mode[] = [
|
|
311
|
+
hljs.COMMENT(/;/, /$/, { relevance: 0 }),
|
|
312
|
+
NESTED_COMMENT,
|
|
313
|
+
DATUM_COMMENT,
|
|
314
|
+
];
|
|
315
|
+
|
|
316
|
+
const IDENT: Mode = {
|
|
317
|
+
begin: IDENT_RE,
|
|
318
|
+
keywords: { $pattern: IDENT_RE, literal: LITERALS },
|
|
319
|
+
relevance: 0,
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
const QUOTED_IDENT: Mode = {
|
|
323
|
+
scope: "symbol",
|
|
324
|
+
begin: regex.concat(/(?:'|#')/, IDENT_RE),
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
// Lists inside a quote, and vectors such as `#(1 2 3)`, are data, so their
|
|
328
|
+
// first element isn't a call. A quasiquoted list can switch back to code
|
|
329
|
+
// with `,` or `,@`.
|
|
330
|
+
const DATA: Mode[] = [];
|
|
331
|
+
const dataLists = (prefix: RegExp | string): Mode[] =>
|
|
332
|
+
[[/\(/, /\)/], [/\[/, /\]/], [/\{/, /\}/]].map(([open, close]) => ({
|
|
333
|
+
begin: regex.concat(prefix, open),
|
|
334
|
+
end: close,
|
|
335
|
+
contains: DATA,
|
|
336
|
+
}));
|
|
337
|
+
|
|
338
|
+
// `#hash(("a" . 1))` and its `#hasheq` and `#hasheqv` variants
|
|
339
|
+
const HASH: Mode = {
|
|
340
|
+
begin: [/'?/, /#hash(?:eqv|eq|alw)?/, /\(/],
|
|
341
|
+
beginScope: { 2: "literal" },
|
|
342
|
+
end: /\)/,
|
|
343
|
+
contains: DATA,
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
const QUOTE_PREFIX = /(?:'|`|#'|#`)/;
|
|
347
|
+
const VECTOR_PREFIX = /#(?:s|&)?/;
|
|
348
|
+
|
|
349
|
+
const BODY: Mode = {
|
|
350
|
+
endsWithParent: true,
|
|
351
|
+
relevance: 0,
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
const NAME: Mode = {
|
|
355
|
+
scope: "name",
|
|
356
|
+
relevance: 0,
|
|
357
|
+
begin: IDENT_RE,
|
|
358
|
+
keywords: KEYWORDS_DICT,
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
// In Racket, square brackets mostly hold bindings and clauses, such as
|
|
362
|
+
// `[x 1]` in a `let` or `[else 0]` in a `cond`, so their first element is
|
|
363
|
+
// only highlighted when it is a keyword.
|
|
364
|
+
const CLAUSE_HEAD: Mode = {
|
|
365
|
+
relevance: 0,
|
|
366
|
+
begin: IDENT_RE,
|
|
367
|
+
keywords: KEYWORDS_DICT,
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
// `(lambda (x y) ...)`: the parameters are not a call.
|
|
371
|
+
const LAMBDA: Mode = {
|
|
372
|
+
begin: /(?:lambda|λ)(?=\s*[([])/,
|
|
373
|
+
beginScope: "keyword",
|
|
374
|
+
endsWithParent: true,
|
|
375
|
+
contains: [
|
|
376
|
+
{
|
|
377
|
+
endsParent: true,
|
|
378
|
+
variants: [
|
|
379
|
+
{ begin: /\(/, end: /\)/ },
|
|
380
|
+
{ begin: /\[/, end: /\]/ },
|
|
381
|
+
],
|
|
382
|
+
contains: [KEYWORD_ARGUMENT, BODY],
|
|
383
|
+
},
|
|
384
|
+
],
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
// `(define (name args) ...)` and its variants, such as `define/contract`.
|
|
388
|
+
const DEFINE_FUNCTION: Mode = {
|
|
389
|
+
begin: [
|
|
390
|
+
/define(?:\/[a-z-]+|-syntax-rule)?/,
|
|
391
|
+
/\s+/,
|
|
392
|
+
/\(/,
|
|
393
|
+
/\s*/,
|
|
394
|
+
IDENT_RE,
|
|
395
|
+
],
|
|
396
|
+
beginScope: { 1: "keyword", 5: "title.function" },
|
|
397
|
+
end: /\)/,
|
|
398
|
+
contains: [BODY],
|
|
399
|
+
};
|
|
400
|
+
|
|
401
|
+
// `(struct name parent (field ...) ...)`: the fields are not a call.
|
|
402
|
+
const STRUCT: Mode = {
|
|
403
|
+
begin: [/struct|define-struct/, /\s+/, IDENT_RE],
|
|
404
|
+
beginScope: { 1: "keyword", 3: "title.class" },
|
|
405
|
+
endsWithParent: true,
|
|
406
|
+
contains: [
|
|
407
|
+
{
|
|
408
|
+
begin: /\(/,
|
|
409
|
+
end: /\)/,
|
|
410
|
+
endsParent: true,
|
|
411
|
+
contains: [BODY],
|
|
412
|
+
},
|
|
413
|
+
IDENT,
|
|
414
|
+
],
|
|
415
|
+
};
|
|
416
|
+
|
|
417
|
+
const LIST: Mode = {
|
|
418
|
+
variants: [
|
|
419
|
+
{ begin: /\(/, end: /\)/ },
|
|
420
|
+
{ begin: /\{/, end: /\}/ },
|
|
421
|
+
],
|
|
422
|
+
// NUMBER comes before NAME so that `(1 3 5)`, a list of `case` values,
|
|
423
|
+
// doesn't show `1` as a call.
|
|
424
|
+
contains: [DEFINE_FUNCTION, STRUCT, LAMBDA, NUMBER, NAME, BODY],
|
|
425
|
+
};
|
|
426
|
+
|
|
427
|
+
const CLAUSE: Mode = {
|
|
428
|
+
begin: /\[/,
|
|
429
|
+
end: /\]/,
|
|
430
|
+
contains: [CLAUSE_HEAD, BODY],
|
|
431
|
+
};
|
|
432
|
+
|
|
433
|
+
// `,(expr)` inside a quasiquoted list is code again.
|
|
434
|
+
const UNQUOTED_LIST: Mode = {
|
|
435
|
+
variants: [
|
|
436
|
+
{ begin: /#?,@?\(/, end: /\)/ },
|
|
437
|
+
{ begin: /#?,@?\{/, end: /\}/ },
|
|
438
|
+
],
|
|
439
|
+
contains: LIST.contains,
|
|
440
|
+
};
|
|
441
|
+
|
|
442
|
+
const UNQUOTED_CLAUSE: Mode = {
|
|
443
|
+
begin: /#?,@?\[/,
|
|
444
|
+
end: /\]/,
|
|
445
|
+
contains: CLAUSE.contains,
|
|
446
|
+
};
|
|
447
|
+
|
|
448
|
+
const UNQUOTED_IDENT: Mode = {
|
|
449
|
+
begin: regex.concat(/#?,@?/, IDENT_RE),
|
|
450
|
+
relevance: 0,
|
|
451
|
+
};
|
|
452
|
+
|
|
453
|
+
const ATOMS: Mode[] = [
|
|
454
|
+
LANG_LINE,
|
|
455
|
+
BOOLEAN,
|
|
456
|
+
CHARACTER,
|
|
457
|
+
REGULAR_EXPRESSION,
|
|
458
|
+
STRING,
|
|
459
|
+
KEYWORD_ARGUMENT,
|
|
460
|
+
NUMBER,
|
|
461
|
+
...COMMENTS,
|
|
462
|
+
];
|
|
463
|
+
|
|
464
|
+
DATA.push(
|
|
465
|
+
...ATOMS,
|
|
466
|
+
UNQUOTED_LIST,
|
|
467
|
+
UNQUOTED_CLAUSE,
|
|
468
|
+
UNQUOTED_IDENT,
|
|
469
|
+
HASH,
|
|
470
|
+
...dataLists(regex.concat(regex.optional(QUOTE_PREFIX), regex.optional(VECTOR_PREFIX))),
|
|
471
|
+
QUOTED_IDENT,
|
|
472
|
+
IDENT,
|
|
473
|
+
);
|
|
474
|
+
|
|
475
|
+
BODY.contains = [
|
|
476
|
+
...ATOMS,
|
|
477
|
+
HASH,
|
|
478
|
+
...dataLists(regex.either(regex.concat(QUOTE_PREFIX, regex.optional(VECTOR_PREFIX)), VECTOR_PREFIX)),
|
|
479
|
+
QUOTED_IDENT,
|
|
480
|
+
IDENT,
|
|
481
|
+
LIST,
|
|
482
|
+
CLAUSE,
|
|
483
|
+
];
|
|
484
|
+
|
|
485
|
+
return {
|
|
486
|
+
name: "Racket",
|
|
487
|
+
aliases: ["rkt"],
|
|
488
|
+
contains: [hljs.SHEBANG(), ...(BODY.contains as Mode[])],
|
|
489
|
+
};
|
|
490
|
+
}
|