codelight.js 1.3.1 → 1.4.0
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/CHANGES.md +9 -0
- package/README.CDN.md +1 -1
- package/README.md +5 -5
- package/SUPPORTED_LANGUAGES.md +35 -8
- package/build/codelight.js +479 -5
- package/build/codelight.min.js +12 -12
- package/es/{chunk-XG43K62Y.js → chunk-KW6EHF3K.js} +479 -5
- package/es/codelight.js +2 -2
- package/es/react.js +2 -2
- package/lib/{chunk-KZATGNQA.cjs → chunk-MX3F3T5L.cjs} +479 -5
- package/lib/codelight.cjs +17 -17
- package/lib/react.cjs +5 -5
- package/package.json +2 -2
package/CHANGES.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 1.4.0
|
|
4
|
+
|
|
5
|
+
- **23 new languages, 50 in all:** Lua, Dart, Elixir, R, Zig, Scala, Haskell, Julia, nginx, Makefile, INI / .env / .properties, Protocol Buffers, Solidity, Groovy / Gradle, Nix, CMake, Prisma, shell sessions, HTTP, SCSS, Mermaid, LaTeX and VBA / VB.NET.
|
|
6
|
+
- **Shell sessions:** `console` and `terminal` blocks now highlight commands after a prompt (`$ `, `user@host:~$ `, `PS C:\> `) and leave output plain, as GitHub does. They used to be coloured entirely as Bash; `sh`, `bash` and `shell` still are.
|
|
7
|
+
- **SCSS:** `scss`, `sass` and `less` now get `//` comments, `$variables`, mixins and nesting. They used to use the plain CSS rules.
|
|
8
|
+
- Code inside strings is highlighted in the new languages too: `${…}` in Dart, Scala, Groovy and Nix; `#{…}` in Elixir and SCSS; `$(…)` in Julia.
|
|
9
|
+
- nginx: `http` in a URL is no longer coloured as the `http` block.
|
|
10
|
+
- Size: 16.3 KB gzipped with all 50 languages.
|
|
11
|
+
|
|
3
12
|
## 1.3.1
|
|
4
13
|
|
|
5
14
|
- Benchmark against highlight.js, Prism and Shiki: docs/benchmark.md, and npm run bench to run it yourself.
|
package/README.CDN.md
CHANGED
|
@@ -6,7 +6,7 @@ Every npm release is on jsDelivr and unpkg. No build step, no install.
|
|
|
6
6
|
|
|
7
7
|
| File | Use |
|
|
8
8
|
|---|---|
|
|
9
|
-
| `build/codelight.min.js` | The script for production. Defines a global `codelight`.
|
|
9
|
+
| `build/codelight.min.js` | The script for production. Defines a global `codelight`. 16 KB gzipped, all 50 languages. |
|
|
10
10
|
| `build/codelight.js` | The same, unminified, for reading and debugging. |
|
|
11
11
|
| `build/styles/default.min.css` | Default theme: light or dark to match the system. |
|
|
12
12
|
| `build/styles/light.min.css` | Light theme. |
|
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ Very fast and lightweight. Only the line being written gets updated, so it stays
|
|
|
15
15
|
|
|
16
16
|
[](https://www.npmjs.com/package/codelight.js)
|
|
17
17
|
[](https://github.com/codelightjs/codelight.js/actions/workflows/ci.yml)
|
|
18
|
-
[](https://www.npmjs.com/package/codelight.js)
|
|
19
19
|
[](https://github.com/codelightjs/codelight.js/blob/main/LICENSE)
|
|
20
20
|
|
|
21
21
|
**[Live demo](https://codelightjs.github.io/)** · **[Documentation](https://github.com/codelightjs/codelight.js/blob/main/docs/README.md)**
|
|
@@ -27,7 +27,7 @@ Very fast and lightweight. Only the line being written gets updated, so it stays
|
|
|
27
27
|
|
|
28
28
|
- **Keeps up with live code.** Each update costs one short line of work, however long the code already is. Re-highlighting the whole block on every update, the usual approach, gets slower as the code grows.
|
|
29
29
|
- **Copes with half-finished Markdown.** Finds code blocks in Markdown that's still arriving, including a fence that hasn't closed and a closing fence that's only half there.
|
|
30
|
-
- **Lightweight, no dependencies.**
|
|
30
|
+
- **Lightweight, no dependencies.** 16 KB gzipped with all 50 languages.
|
|
31
31
|
- **Works anywhere.** Two files from a CDN, an npm package for bundlers, or a React component.
|
|
32
32
|
- **Line numbers, highlighted lines and a copy button,** built in. Copying never includes the line numbers.
|
|
33
33
|
- **Light and dark themes.** Every colour is a CSS variable, and every colour meets WCAG AA contrast.
|
|
@@ -38,7 +38,7 @@ A real 282-line TypeScript file arriving 4 characters at a time (2,538 updates),
|
|
|
38
38
|
|
|
39
39
|
| | Whole file, as it arrives | Per update, late in the file | Finished file, once | Size, gzipped |
|
|
40
40
|
|---|---|---|---|---|
|
|
41
|
-
| **codelight.js** | **7.6 s** | **6.0 ms** | **21 ms** |
|
|
41
|
+
| **codelight.js** | **7.6 s** | **6.0 ms** | **21 ms** | 16.3 KB, 50 languages |
|
|
42
42
|
| highlight.js | 33.9 s | 24 ms | 23 ms | 11.1 KB, 1 language |
|
|
43
43
|
| Prism | 35.3 s | 30 ms | 23 ms | 7.7 KB, 1 language |
|
|
44
44
|
| Shiki | 218 s | 190 ms | 175 ms | 71.6 KB, 1 language |
|
|
@@ -165,7 +165,7 @@ Full details: [API reference](https://github.com/codelightjs/codelight.js/blob/m
|
|
|
165
165
|
|
|
166
166
|
## Languages
|
|
167
167
|
|
|
168
|
-
|
|
168
|
+
50 languages, including JavaScript, TypeScript, Python, Bash, SQL, HTML, CSS, Kotlin, Swift, Dart, Lua, R, Terraform, Dockerfile, HTTP, Mermaid and LaTeX, plus terminal sessions. See [SUPPORTED_LANGUAGES.md](https://github.com/codelightjs/codelight.js/blob/main/SUPPORTED_LANGUAGES.md) for the full list and every alias. An unknown language shows as plain text, safely escaped.
|
|
169
169
|
|
|
170
170
|
## Themes
|
|
171
171
|
|
|
@@ -215,7 +215,7 @@ codelight.js is built for code that's still arriving. For other jobs there are b
|
|
|
215
215
|
- **Docs sites and blogs** with finished code: [Shiki](https://shiki.style) gives VS Code-accurate colours for 200+ languages, and [highlight.js](https://highlightjs.org) or [Prism](https://prismjs.com) cover far more languages.
|
|
216
216
|
- **A React chat app that already uses Shiki**: [Streamdown](https://streamdown.ai) renders streaming Markdown with Shiki highlighting, and [`@shikijs/stream`](https://shiki.style/packages/stream) streams Shiki itself.
|
|
217
217
|
|
|
218
|
-
codelight.js is the small option: no dependencies, no WebAssembly, any framework, and accurate enough for the
|
|
218
|
+
codelight.js is the small option: no dependencies, no WebAssembly, any framework, and accurate enough for the 50 languages people write most. Its highlighting is rule-based, so unusual syntax can be coloured less precisely than in Shiki.
|
|
219
219
|
|
|
220
220
|
## Contributing
|
|
221
221
|
|
package/SUPPORTED_LANGUAGES.md
CHANGED
|
@@ -1,41 +1,67 @@
|
|
|
1
1
|
# Supported languages
|
|
2
2
|
|
|
3
|
-
All
|
|
3
|
+
All 50 are in every build. Use the name or any alias as the `lang` option, a `data-lang` attribute, or a `language-xxx` class. Names and aliases aren't case-sensitive.
|
|
4
4
|
|
|
5
5
|
| Language | Name | Aliases |
|
|
6
6
|
|---|---|---|
|
|
7
|
-
| Bash, shell | `bash` | `sh`, `shell`, `zsh`, `shellscript
|
|
7
|
+
| Bash, shell scripts | `bash` | `sh`, `shell`, `zsh`, `shellscript` |
|
|
8
8
|
| C | `c` | `h` |
|
|
9
9
|
| C++ | `cpp` | `c++`, `cc`, `cxx`, `hpp` |
|
|
10
10
|
| C# | `csharp` | `cs`, `c#` |
|
|
11
|
-
|
|
|
11
|
+
| CMake | `cmake` | `cmakelists.txt` |
|
|
12
|
+
| CSS | `css` | |
|
|
13
|
+
| Dart | `dart` | |
|
|
12
14
|
| Diff, patch | `diff` | `patch` |
|
|
13
15
|
| Dockerfile | `dockerfile` | `docker`, `containerfile` |
|
|
16
|
+
| Elixir | `elixir` | `ex`, `exs`, `heex` |
|
|
14
17
|
| Go | `go` | `golang` |
|
|
15
18
|
| GraphQL | `graphql` | `gql` |
|
|
19
|
+
| Groovy, Gradle | `groovy` | `gradle`, `gvy`, `jenkinsfile` |
|
|
20
|
+
| Haskell | `haskell` | `hs`, `lhs` |
|
|
16
21
|
| HTML, XML, SVG | `xml` | `html`, `xhtml`, `svg`, `vue`, `svelte` |
|
|
22
|
+
| HTTP requests and responses | `http` | `https`, `rest`, `rest-client` |
|
|
23
|
+
| INI, .env, .properties | `ini` | `cfg`, `env`, `dotenv`, `properties`, `editorconfig`, `gitconfig` |
|
|
17
24
|
| Java | `java` | |
|
|
18
25
|
| JavaScript, JSX | `javascript` | `js`, `jsx`, `mjs`, `cjs`, `node` |
|
|
19
26
|
| JSON | `json` | `jsonc`, `json5` |
|
|
27
|
+
| Julia | `julia` | `jl` |
|
|
20
28
|
| Kotlin | `kotlin` | `kt`, `kts` |
|
|
29
|
+
| LaTeX, TeX | `latex` | `tex`, `context` |
|
|
30
|
+
| Lua | `lua` | `luau` |
|
|
31
|
+
| Makefile | `makefile` | `make`, `mk`, `mak`, `gnumakefile` |
|
|
21
32
|
| Markdown | `markdown` | `md`, `mdx` |
|
|
33
|
+
| Mermaid diagrams | `mermaid` | `mmd` |
|
|
34
|
+
| nginx | `nginx` | `nginx.conf` |
|
|
35
|
+
| Nix | `nix` | |
|
|
22
36
|
| PHP | `php` | |
|
|
23
37
|
| Plain text | `plaintext` | `text`, `txt`, `plain` |
|
|
24
38
|
| PowerShell | `powershell` | `ps1`, `pwsh`, `ps` |
|
|
39
|
+
| Prisma | `prisma` | |
|
|
40
|
+
| Protocol Buffers | `protobuf` | `proto`, `proto3` |
|
|
25
41
|
| Python | `python` | `py`, `python3` |
|
|
42
|
+
| R | `r` | `rscript` |
|
|
26
43
|
| Ruby | `ruby` | `rb` |
|
|
27
44
|
| Rust | `rust` | `rs` |
|
|
45
|
+
| Scala | `scala` | `sc` |
|
|
46
|
+
| SCSS, Sass, Less | `scss` | `sass`, `less` |
|
|
47
|
+
| Shell session (commands and output) | `shellsession` | `console`, `terminal`, `shell-session`, `sh-session` |
|
|
48
|
+
| Solidity | `solidity` | `sol` |
|
|
28
49
|
| SQL | `sql` | `postgres`, `postgresql`, `mysql`, `sqlite`, `plsql` |
|
|
29
50
|
| Swift | `swift` | |
|
|
30
51
|
| Terraform, HCL | `hcl` | `terraform`, `tf`, `tfvars`, `opentofu` |
|
|
31
52
|
| TOML | `toml` | |
|
|
32
53
|
| TypeScript | `typescript` | `ts`, `mts`, `cts` |
|
|
33
54
|
| TypeScript with JSX | `tsx` | |
|
|
55
|
+
| VBA, VB.NET, VBScript | `vba` | `vb`, `vbnet`, `vb.net`, `vbscript`, `vbs`, `visual-basic` |
|
|
34
56
|
| YAML | `yaml` | `yml` |
|
|
57
|
+
| Zig | `zig` | |
|
|
35
58
|
|
|
36
59
|
**Code inside strings is highlighted as code:** `${…}` in JavaScript, TypeScript, Kotlin and Terraform; `{…}` in Python f-strings and C# `$"…"` strings; `\(…)` in Swift; `$(…)` in PowerShell.
|
|
37
60
|
|
|
38
61
|
**Other details:**
|
|
62
|
+
- Shell sessions highlight lines after a prompt (`$ `, `user@host:~$ `, `(venv) $ `, `PS C:> `) as Bash, and leave the output plain. A command ending in `` continues on the next line.
|
|
63
|
+
- HTTP highlights the request or status line and headers, then the body as JSON. `###` separates requests, as in `.http` files.
|
|
64
|
+
- In SCSS, the `//` inside `url(https://…)` isn't treated as a comment.
|
|
39
65
|
- HTML highlights JavaScript inside `<script>` and CSS inside `<style>`. Vue and Svelte files are highlighted as HTML, so their templates, scripts and styles all get colour.
|
|
40
66
|
- JavaScript regex literals are recognised.
|
|
41
67
|
- Bash and Terraform heredocs (`<<EOF` … `EOF`) are recognised.
|
|
@@ -50,13 +76,14 @@ An unknown language shows as plain, escaped text.
|
|
|
50
76
|
import { defineLanguage, registerLanguage } from "codelight.js";
|
|
51
77
|
|
|
52
78
|
registerLanguage(
|
|
53
|
-
"
|
|
79
|
+
"gleam",
|
|
54
80
|
defineLanguage({
|
|
55
|
-
lineComment: ["
|
|
56
|
-
strings: [{ open: '"' }],
|
|
57
|
-
|
|
81
|
+
lineComment: ["//"],
|
|
82
|
+
strings: [{ open: '"', multiline: true }],
|
|
83
|
+
keywords: "as assert case const fn if import let opaque panic pub todo type use",
|
|
84
|
+
constants: "True False Nil",
|
|
85
|
+
classNames: true,
|
|
58
86
|
}),
|
|
59
|
-
["cfg", "conf"],
|
|
60
87
|
);
|
|
61
88
|
```
|
|
62
89
|
|