@aljazmc/syntax 0.3.0 → 0.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/README.md +16 -1
- package/bin/index.js +1515 -2
- package/bin/types/index.d.ts +8 -1
- package/bin/types/markdown/ast.d.ts +156 -0
- package/bin/types/markdown/blocks.d.ts +15 -0
- package/bin/types/markdown/inlines.d.ts +7 -0
- package/bin/types/markdown/scan.d.ts +10 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# > syntax
|
|
2
2
|
|
|
3
3
|
Shared, dependency-free scanner and recursive descent parser for JavaScript,
|
|
4
|
-
TypeScript, JSX and
|
|
4
|
+
TypeScript, JSX, JSON and Markdown, bundled into `@aljazmc/formatero` and `@aljazmc/lintero`, and published for their
|
|
5
5
|
types.
|
|
6
6
|
|
|
7
7
|
```ts
|
|
@@ -16,3 +16,18 @@ Invalid sources throw `ParseError` with the position of the problem.
|
|
|
16
16
|
|
|
17
17
|
`Walker.children(node)` lists the child nodes of a node in source order, and
|
|
18
18
|
`Lines` turns offsets into 1-based lines and columns, for messages.
|
|
19
|
+
|
|
20
|
+
Markdown is parsed like CommonMark, with GitHub's tables, task list items
|
|
21
|
+
and strikethrough:
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import { isMarkdown, parseMarkdown } from "@aljazmc/syntax";
|
|
25
|
+
|
|
26
|
+
isMarkdown("README.md"); // true
|
|
27
|
+
const root = parseMarkdown("# Title\n\n- [x] done\n");
|
|
28
|
+
// root.children: a Heading and a List, with their offsets and lines
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Blocks have offsets into the source and 1-based lines, and keep what a
|
|
32
|
+
formatter needs to print them as written, like the indentation of each
|
|
33
|
+
line. Inlines have offsets into the text of their block.
|