@aljazmc/syntax 0.7.2 → 0.7.3
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/README.md +42 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,12 +1,30 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @aljazmc/syntax
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
[](https://github.com/aljazmc/aljazmc/actions/workflows/cicd.yml)
|
|
4
|
+
[](https://www.npmjs.com/package/@aljazmc/syntax)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
[](package.json)
|
|
7
|
+
[](https://github.com/estree/estree)
|
|
8
|
+
[](https://github.github.com/gfm/)
|
|
9
|
+
[](../../README.md#packages)
|
|
10
|
+
[](#tests)
|
|
11
|
+
[](https://www.typescriptlang.org/)
|
|
8
12
|
|
|
9
|
-
|
|
13
|
+
The scanner and recursive descent parsers behind formatero and lintero,
|
|
14
|
+
for CSS, HTML, JavaScript, JSON, JSX, Markdown, TypeScript and YAML, in
|
|
15
|
+
plain TypeScript. esbuild bundles this code into both packages; it is
|
|
16
|
+
published on npm only for its types.
|
|
17
|
+
|
|
18
|
+
## Features
|
|
19
|
+
|
|
20
|
+
- **Eight languages, one package.** Every parser is hand-written, with no
|
|
21
|
+
generated grammars and no dependencies.
|
|
22
|
+
- **ESTree trees.** JavaScript, JSX, TypeScript and JSON parse to ESTree,
|
|
23
|
+
with Babel-style literals and TypeScript nodes.
|
|
24
|
+
- **Comments kept.** Every parser keeps the comments, and HTML its
|
|
25
|
+
whitespace, as a formatter needs them.
|
|
26
|
+
- **Precise errors.** Invalid sources throw a `ParseError` with the line
|
|
27
|
+
and column of the problem; CSS can recover and list them instead.
|
|
10
28
|
|
|
11
29
|
| Language | Entry points | Tree |
|
|
12
30
|
| --------------------------- | ----------------------------- | ---------------------------------------------------------------------------------- |
|
|
@@ -25,7 +43,7 @@ problem.
|
|
|
25
43
|
| `tagOf` | The known tag of an element name, like `div` for `DIV`. |
|
|
26
44
|
| `Walker` | Lists the child nodes of a node in source order. |
|
|
27
45
|
|
|
28
|
-
##
|
|
46
|
+
## Usage
|
|
29
47
|
|
|
30
48
|
```ts
|
|
31
49
|
import {
|
|
@@ -44,6 +62,21 @@ const doc = parseMarkdown("# Title\n\n- [x] done\n");
|
|
|
44
62
|
const stream = parseYaml("a:\n - b: 1 # c\n");
|
|
45
63
|
```
|
|
46
64
|
|
|
47
|
-
##
|
|
65
|
+
## Tests
|
|
66
|
+
|
|
67
|
+
```sh
|
|
68
|
+
docker compose run --rm node yarn t:syntax
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
31 tests, run by [testero](../../packages/testero), each checking many
|
|
72
|
+
sources: JavaScript, JSX and TypeScript, Markdown blocks and inlines by
|
|
73
|
+
CommonMark, HTML, CSS and YAML, and regressions. formatero and lintero
|
|
74
|
+
test the parser further, through 1,898 cases of their own that compare
|
|
75
|
+
with Biome.
|
|
76
|
+
|
|
77
|
+
A change here is bundled into formatero and lintero, so run their tests
|
|
78
|
+
too: `yarn t:formatero` and `yarn t:lintero`.
|
|
79
|
+
|
|
80
|
+
## License
|
|
48
81
|
|
|
49
82
|
MIT, see [LICENSE](LICENSE).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aljazmc/syntax",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"description": "Shared, dependency-free parser for CSS, HTML, JavaScript, JSON, JSX, Markdown, TypeScript and YAML, bundled into @aljazmc/formatero and @aljazmc/lintero.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"parser",
|